Answer the question
In order to leave comments, you need to log in
Why doesn't Orchid custom filtering select multiple options?
Laravel 8.53
Admin Panel: Orchid
php: 8.0
When searching in a custom filter, when selecting multiple fields, only the last 1 field is always substituted.
For example, the filter consists of 4 fields: City, Category, Brand, Model.
If you select City, then there will be records by city, but if you then select Category or another field, then the search will be only for the last selected field, and the first condition is deleted.
Made according to the video guide from Ilya Chubarov " Laravel
Orchid Admin Panel. Lesson #15. Advanced Filtering
"
public $parameters = ['town'];
public function name(): string
{
return 'Город';
}
public function run(Builder $builder): Builder
{
return $builder->where('id_town', $this->request->get('town'));
}
public function display(): array
{
return [
Select::make('town')
->options(TownModel::orderBy('title','asc')->get()->pluck('title','id'))
->empty()
->value($this->request->get('town'))
->title('Город')
];
}
public function filters(): array
{
return [
TownFilter::class,
CategoryFilter::class,
VehicleMarksFilter::class,
VehicleModelsFilter::class
];
}
public function query(): array
{
return [
'vehicle_products' => VehicleProductModel::filtersApplySelection(FilterVehicleProductsSelection::class)->filters()->defaultSort('up_at','asc')->paginate(20)
];
public function layout(): array
{
return [
FilterVehicleProductsSelection::class,
VehicleProductsTable::class,
];
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question