-
Hello I am trying to do something slightly different with the filters that when a Project is selected, the options in the Wall-Elevation-Floor-Zone filter change. I have the following code but i believe Does any one have any suggestions for this? $filters[] = MultiSelectDropdownFilter::make('Wall, Elevation, Floor, Zone')
->options($this->builder()
->select('wall_elevation_floor')
->when($this->getAppliedFilters()['project'], function ($query) {
$query->whereRelation('schedule', 'project', $this->getAppliedFilters()['project']);
})
->groupBy('wall_elevation_floor')
->orderBy('wall_elevation_floor', 'desc')
->pluck('wall_elevation_floor', 'wall_elevation_floor')->toArray())
->filter(function (Builder $builder, array $values) {
$builder->whereIn('wall_elevation_floor', $values);
}); Thanks Richard. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
For anyone else, I answered by using Livewire Hooks public $filterProject;
public function mount(): void
{
$this->filterProject = request()->get('table-filters')['project'] ?? null;
}
public function updating($name, $value): void
{
if ($name === 'filterComponents.project') {
$this->filterProject = $value;
$this->setFilter('wall,_elevation,_floor,_zone', null);
}
}
// FILTER
// Wall, Elevation, Floor, Zone
$filters[] = MultiSelectDropdownFilter::make('Wall, Elevation, Floor, Zone')
->options($this->builder()
->select('wall_elevation_floor')
->when($this->filterProject, function ($query) {
$query->whereRelation('schedule', 'project', $this->filterProject);
})
->groupBy('wall_elevation_floor')
->orderBy('wall_elevation_floor', 'desc')
->pluck('wall_elevation_floor', 'wall_elevation_floor')->toArray())
->filter(function (Builder $builder, array $values) {
$builder->whereIn('wall_elevation_floor', $values);
}); |
Beta Was this translation helpful? Give feedback.
-
There are some events and hooks that you could listen to too e.g.
|
Beta Was this translation helpful? Give feedback.
For anyone else, I answered by using Livewire Hooks