Replies: 2 comments 6 replies
-
public function filters(): array
{
// Should probably get from cache so you don't hit the database on each render
$myOptions = Model::where('this', 'that')->get()->toArray();
return [
'options' => Filter::make('Active')
->select(
array_merge([
'' => 'Any',
'yes' => 'Yes',
'no' => 'No',
], $myOptions)
),
];
} |
Beta Was this translation helpful? Give feedback.
5 replies
-
If categories is a one to many, you have to check the relationship. Something like: ->when($this->getFilter('options'), fn($query, $option) => $query->whereHas('categories', function($query) use($option) {
return $query->where('name', $option);
}); Or something like that. You have to debug until you find where your query is wrong. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hi Anthony
filters WORK EG ```
'categories' => Filter::make('categories')
->select([
'' => 'All',
'uncategorized' => 'uncategorized',
//'no' => 'No',
]),
BUT I CANNOT ADD 100 'S OF OPTIONS dynamically AT run Time
how do i do it because i will not know the categories until runtime when program is running. The categories are stored in another table and must be loaded at runtime
Beta Was this translation helpful? Give feedback.
All reactions