I would like to force some filters (for example status must be published unless you are admin)
my tests with and without filter params:
$response = $this->get($this->apiUrl.'?filter[status]='.EventStatus::Published); // this works
$response = $this->get($this->apiUrl); // doesnt work with forced filters
Controller:
$request->merge([
'filter' => [
'status' => EventStatus::Published
]
]);
dd($request->all()); // shows 'status' => 'published' for both tests
$events = QueryBuilder::for(Event::class)
->allowedFilters(['status'])
->jsonPaginate();
// $events includes all published and private events when query params filters not used
Am I doing something wrong or how this case should be handled?
Hello,
I would like to force some filters (for example status must be published unless you are admin)
my tests with and without filter params:
Controller:
Am I doing something wrong or how this case should be handled?