DEV Community

Discussion on: Making the advanced query filter with Eloquent Filter in Laravel

Collapse
 
jorenthijs profile image
Joren Thijs

I am new to Laravel and am using your package in a school project and it works like a charm👍

I do however wanna give you a heads up about one small bug i have seemed to run into.
When combining your filter with a paginator it correctly ignores the page query parameter:
'my-url.com/api/resource?page=5'

But it doesn't seem to ignore the perPage query parameter:
'my-url.com/api/resource?page=5&perPage=100'
This causes a code 500 response.
With an error asking met to add it to the whitelist. (Laravel V7.0)

Collapse
 
mehdifathi profile image
Mehdi Fathi • Edited

Thanks, you can use this code

$perpage = Request::input('perpage');
Request::offsetUnset('perpage');
$users = User::filter($modelFilters)->with('posts')->orderByDesc('id')->paginate($perpage,['*'],'page');

You can make every param for your self but you can unset before send to filter method model