vendredi 19 octobre 2018

Laravel Query Builder pass multiple parameters as comma seperated list not working

I am using the spatie/laravel-query-builder to make a scope filter. In the documentation I read this:

You can even pass multiple parameters to the scope by passing a comma separated list to the filter:

GET /events?filter[starts_between]=2018-01-01,2018-12-31

So I made a scope filter in my model that looks like this:

public function scopeStartsBetween(Builder $query, $dates): Builder
{
    dd($dates);

    return $query->whereBetween('created_at', array($dates[0], $dates[1]));
}

My request looks like this:

http://127.0.0.1:8000/?filter[starts_between]=2018-10-15,2018-10-17

The result of the dd($dates) is this:

"2018-10-15"

So the comma seperated list for multiple parameters doesn't work, or am I doing something wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire