Using Query Builder to filter an entry by an Array field type.

Hey guys for the Query Builder, how do I filter an Entry collection if the column's field type is YAML or an Array?

I tried this (where fields is a yaml field type): $query->where('fields.department', '=' , 'Test'); //Does not return anything.


What's weird is that if I use not equal it returns all entries: $query->where('fields.department', '<>' , 'Test'); So I guess it's comparing something just not the right column.

I tried this to see if the column is there and yes it outputs the department values:

$query->get()->filter(function ($value,  $key) {

I'm using this inside a Scope class so I don't think I can use filter? If there is a way to return the $query with the filter applied then I'm okay with it too.

Whole code:

class Jobs extends Scope
     * Apply the scope.
     * @param \Statamic\Query\Builder $query
     * @param array $values
     * @return void
    public function apply($query, $values)
        $department = request()->get('department');
        $query->where('fields.department', '=' , $department);

Antler:{{ collection from="jobs" limit="15" sort="id:desc" as="jobs" paginate="true" query_scope="jobs" }}

>>>>>>> Unanswered <<<<<<<
0 Replies
1 Follower