dillingham / formation

Laravel search, sort, and filters
MIT License
0 stars 0 forks source link

add filtered() method with values #23

Closed dillingham closed 2 years ago

dillingham commented 2 years ago

debating on a $request->filtered() method that gets all values and requests models for related() filters

this would allow to return an array of filters to the app to populate initial state

public function filtered(): array
    {
        return collect($this->filters())
            ->filter(function($filter) {
               return Request::filled($filter->publicKey);
            })->mapWithKeys(function($filter) {
                return [$filter->publicKey => 1];
            })->toArray();
    }