spatie / laravel-query-builder

Easily build Eloquent queries from API requests
https://spatie.be/docs/laravel-query-builder
MIT License
4.02k stars 395 forks source link

AllowedFilter::scope is not accessing the updated request #859

Closed ajGulati05 closed 1 year ago

ajGulati05 commented 1 year ago

I have a middleware that converts the filter['starts_between'] to datetime. The original is just in date. The request that the controller gets also has the updated request but the filter uses the original request object not the updated one. Is there a reason behind this or an actual bug?

ajGulati05 commented 1 year ago

Went through the code and realized package accesses the global request. Workaround was to pass the request in QueryBuilder

QueryBuilder::for($query, new Request(['filter' => $request->input('filter', [])]))