© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•17mo ago•
1 reply
nowak

Duplicate notifications from table action on page load

I have a UserOrderResource, where I have added a table action that navigates to the GroupOrderResource record for each UserOrder record:
Tables\Actions\Action::make('group_order')
  ->url(function (UserOrder $record): ?string {
    // Use the already eager-loaded groupOrder if it's available
    $groupOrder = $record->groupOrder()->withTrashed()->first();

    // Check if the groupOrder exists and is not trashed
    if (!$groupOrder || $groupOrder->trashed()) {

      // Show a notification to the user
      Notification::make()
          ->warning()
          ->title('Group Order Not Available')
          ->body("The group order for the user order by {$record->detail->full_name} with deadline: {$record->deadline} and id: {$record->id} is no longer available.")
          ->persistent()
          ->send();

      return null; // Halt the action by not returning a URL
    }
    return GroupOrderResource::getUrl('edit', ['record' => $groupOrder]);
  }),
Tables\Actions\Action::make('group_order')
  ->url(function (UserOrder $record): ?string {
    // Use the already eager-loaded groupOrder if it's available
    $groupOrder = $record->groupOrder()->withTrashed()->first();

    // Check if the groupOrder exists and is not trashed
    if (!$groupOrder || $groupOrder->trashed()) {

      // Show a notification to the user
      Notification::make()
          ->warning()
          ->title('Group Order Not Available')
          ->body("The group order for the user order by {$record->detail->full_name} with deadline: {$record->deadline} and id: {$record->id} is no longer available.")
          ->persistent()
          ->send();

      return null; // Halt the action by not returning a URL
    }
    return GroupOrderResource::getUrl('edit', ['record' => $groupOrder]);
  }),

I tried to add the conditional logic and notification to
->before()
->before()
, but it was ignored entirely and when clicking the action, so I added this logic directly to the
->url()
->url()
method.
But I experience some strange behaviour, as these notifications are sent when the table is loaded, which makes sense as the url is generated before the action is clicked. But each notification is sent twice, which is odd to me.
Is this due to my action code, or is filament triggering the action code twice on page load?
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

Call action after page load to table mount action
FilamentFFilament / ❓┊help
2y ago
Reload table results from Page Action
FilamentFFilament / ❓┊help
3y ago
Relationship table on modal? or NEW action on table action page?
FilamentFFilament / ❓┊help
2y ago
Duplicate Notifications on data import
FilamentFFilament / ❓┊help
3y ago