Add group filter and custom options to a backend list
5
Given this table:
| title | genre |
| -------| --------- |
| Book 1 | Academia |
| Book 2 | Biography |
| Book 3 | Children |
| Book 4 | Fiction |
| Book 5 | Biography |
In your plugin directory create the following file:
controllers/yourcontroller/config_filter.yaml
inside config_filter.yaml
scopes:
genre:
label: Filter Genres
modelClass: Path\To\Models\Model
type: group
conditions: genre in (:filtered)
options: listGenres
on your model create a method listGenres
public function listGenres()
{
// you can use distinct or groupBy
return Model::groupBy->('genre')->pluck('genre', 'genre')->toArray();
}
There are no comments yet
Be the first one to comment