Options with multiple condition.

Good evening, how to list an option from database with multiple condition ? At the moment im still using relationship and only have 1 condition.
Select::make('parent_id')
->label('Category')
->relationship('mainCategory', 'name', fn (Builder $query)
=>$query->where('parent_id', '=', NULL))
->searchable()
->placeholder('Select parent category'),
Select::make('parent_id')
->label('Category')
->relationship('mainCategory', 'name', fn (Builder $query)
=>$query->where('parent_id', '=', NULL))
->searchable()
->placeholder('Select parent category'),
What i want to achieve is, the option will only show category with parent_id is null and the status is active.
Solution:
Just chain another where() clause on.
Jump to solution
3 Replies
Solution
cheesegrits
cheesegrits9mo ago
Just chain another where() clause on.
einnlleinhatt_
einnlleinhatt_9mo ago
How do I make it works using ->options ?
einnlleinhatt_
einnlleinhatt_9mo ago
Thanks, also fixed it by removing searchable.