© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
Laurens

Custom widget property being set after widget reload in action

I'm using the following custom action to navigate between between weeks of upcoming birthdays users. When the action runs, we increment the start date property. However, the property seems to lag a week behind the actual value. I believe this is happening due to the reload happening before the property is being set? How can I prevent this?

class BirthdayMembersWidget extends BaseWidget
{
    public Carbon $startDate;

    public function mount(): void
    {
        $this->startDate = today();
    }

    protected function getTableHeaderActions(): array
    {
        return [
            Tables\Actions\Action::make('Next')
                ->label(new HtmlString('»'))
                ->action(function () {
                    $this->startDate = $this->startDate->addWeek();
                }),
        ];
    }

    protected function getTableQuery(): Builder
    {
        $startDate = $this->getStartDate();
        $endDate = $this->getEndDate();

        return User::query()
            ->select(['id', 'full_name', 'birthday'])
            ->whereBirthday($startDate, $endDate)
            ->orderByBirthday();
    }
class BirthdayMembersWidget extends BaseWidget
{
    public Carbon $startDate;

    public function mount(): void
    {
        $this->startDate = today();
    }

    protected function getTableHeaderActions(): array
    {
        return [
            Tables\Actions\Action::make('Next')
                ->label(new HtmlString('»'))
                ->action(function () {
                    $this->startDate = $this->startDate->addWeek();
                }),
        ];
    }

    protected function getTableQuery(): Builder
    {
        $startDate = $this->getStartDate();
        $endDate = $this->getEndDate();

        return User::query()
            ->select(['id', 'full_name', 'birthday'])
            ->whereBirthday($startDate, $endDate)
            ->orderByBirthday();
    }


Thanks in advance!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Reload Page after custom action ends.
FilamentFFilament / ❓┊help
3y ago
How to Reload Dashboard Widget from Other Widget after Modal Action?
FilamentFFilament / ❓┊help
3y ago
Custom widget action steps
FilamentFFilament / ❓┊help
12mo ago
return custom table widget in action
FilamentFFilament / ❓┊help
3y ago