spatie / laravel-query-builder

Easily build Eloquent queries from API requests

Home Page:https://spatie.be/docs/laravel-query-builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comma separated list seems to not work on scopes

K2ouMais opened this issue · comments

Hello everyone,

I am using a route like this:

/api/user?filter[userId]=1,2,3

In the controller I use a scope to query the id.

AllowedFilter::scope('userId')

The scope in the model:

public function scopeUserId(Builder $query, $id): Builder
{
    dd($id); // output: 1
    return $query->where('id', $id);
}

The output of dd($id) seems to only be the first value of the comma separated list.

Is this correct? What am I doing wrong? I am expecting it to be 1,2,3.

Thank you in advance.