[Bug]: not applying changes from dashboard filters
What happened?
i have my widget inside a dashboard that has some filters and they are updating live() . in the calendar widget i have used InteractsWithPageFilters trait and i can read the value from the dashboard filters but they are only applied when i refresh the page not by changing the filters value . code provided
dashboard filter form 👇
public function filtersForm(Form $form): Form
{
return $form
->schema([
Section::make()
->schema([
Select::make('hall')
->multiple()
->live()
->searchable()
->preload()
->options(Hall::pluck('name', 'id')->toArray())
->getOptionLabelsUsing(fn (array $values): array => Hall::whereIn('id', $values)->pluck('name', 'id')->toArray()),
])
->columnSpanFull(),
]);
}
in the calendar widget 👇
public function getEvents(array $fetchInfo = []): Collection|array
{
$hallIds = fluent($this->filters)->get('hall');
return ReservationDay::
where('start_date', '>=', $fetchInfo['start'])
->where('end_date', '<=', $fetchInfo['end'])
->when($hallIds, function ($query) use ($hallIds) {
$query->whereHas('reservation', function ($query) use ($hallIds) {
$query->whereIn('hall_id', $hallIds);
});
})
->with(['reservation.hall', 'reservation.user'])->get();
}
how can i make it when the filter changes the getEvents gets called again ?
How to reproduce the bug
create a filter on the main dashboard and try to use these filter values live
Package Version
1.13
PHP Version
8.2
Laravel Version
11.x
Which operating systems does with happen with?
macOS
Notes
No response
for anyone face the same issue i solved it by dispatching the event after the state updated
->afterStateUpdated(fn ($state) => $this->dispatch('calendar--refresh'))