class Commissions extends Page
{
use HasFiltersAction, HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-banknotes';
protected static string $view = 'filament.pages.commissions';
protected static ?string $navigationGroup = 'On-Site';
public $year; // Declare year property to hold the selected year
protected function getHeaderActions(): array
{
return [
FilterAction::make()
->form([
Select::make('year')
->options([
2024 => '2024',
2023 => '2023',
2022 => '2022',
'all' => 'All',
])
->native(false)
->afterStateUpdated(function ($state){
$this->year = $state; // Set the selected year
$this->updateWidgets(); // Update the widgets with the new filter
}),
]),
];
}
protected function updateWidgets()
{
$this->dispatch('filtersUpdated', [
'year' => $this->year, // Dispatch the year state when the filter is updated
]);
}
}
class Commissions extends Page
{
use HasFiltersAction, HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-banknotes';
protected static string $view = 'filament.pages.commissions';
protected static ?string $navigationGroup = 'On-Site';
public $year; // Declare year property to hold the selected year
protected function getHeaderActions(): array
{
return [
FilterAction::make()
->form([
Select::make('year')
->options([
2024 => '2024',
2023 => '2023',
2022 => '2022',
'all' => 'All',
])
->native(false)
->afterStateUpdated(function ($state){
$this->year = $state; // Set the selected year
$this->updateWidgets(); // Update the widgets with the new filter
}),
]),
];
}
protected function updateWidgets()
{
$this->dispatch('filtersUpdated', [
'year' => $this->year, // Dispatch the year state when the filter is updated
]);
}
}