mohammad-fouladgar/eloquent-builder

Multiple same id filter

exSnake opened this issue · 1 comments

Is it possible to filter multiple element of the same id using a separator?

localhost/users?filter['name']=michael,john,jack&filter['surname']=jackson

@exSnake, Yes, it's possible. You can do it in two ways.

The first way is like below:

localhost/users?filter[name][]=michael&filter[name][]=john&filter[name][]=jack

That the `$vaue' in your filter is a type of array:

public function apply(Builder $builder, $value): Builder
{
   dd($value); // array
}

And also, you can try it:

localhost/users?filter['name']=michael,john,jack&filter['surname']=jackson

And you have to explode the value like this:

public function apply(Builder $builder, $value): Builder
{
   $value = explode(',', $value);
   dd($value); // array
}