© 2026 Hedgehog Software, LLC

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

How to add a link to resource entry in a database notification?

I have a Controller in my laravel app that gets triggered when a create record form is submitted from a Vue frontend, and I am wondering how to add an action to the notification that navigates to the created record.
I tried this:
return DB::transaction(function () use ($input) {
  $complaint = new UserOrderComplaint([
    'user_order_id' => $input['user_order_id'],
    'reason' => $input['reason'],
    'status' => $input['status'],
  ]);

  $complaint->save();

  // Notify all users with the super_admin role
  $superAdmins = User::role('super_admin')->get();

  foreach ($superAdmins as $superAdmin) {
    Notification::make()
      ->title('New User Order Complaint')
      ->body('A new complaint has been submitted.')
      ->actions([
        Action::make('view')
          ->button()
          ->url(fn ($complaint): string => UserOrderComplaintResource::getUrl('edit', ['complaint' => $complaint->id])),
      ])
      ->sendToDatabase($superAdmin);
    event(new DatabaseNotificationsSent($superAdmin));
  }

  return $complaint;
});
return DB::transaction(function () use ($input) {
  $complaint = new UserOrderComplaint([
    'user_order_id' => $input['user_order_id'],
    'reason' => $input['reason'],
    'status' => $input['status'],
  ]);

  $complaint->save();

  // Notify all users with the super_admin role
  $superAdmins = User::role('super_admin')->get();

  foreach ($superAdmins as $superAdmin) {
    Notification::make()
      ->title('New User Order Complaint')
      ->body('A new complaint has been submitted.')
      ->actions([
        Action::make('view')
          ->button()
          ->url(fn ($complaint): string => UserOrderComplaintResource::getUrl('edit', ['complaint' => $complaint->id])),
      ])
      ->sendToDatabase($superAdmin);
    event(new DatabaseNotificationsSent($superAdmin));
  }

  return $complaint;
});

Where I get this error:
Error creating complaint: An attempt was made to evaluate a closure for [Filament\Notifications\Actions\Action], but [$complaint] was unresolvable.
Error creating complaint: An attempt was made to evaluate a closure for [Filament\Notifications\Actions\Action], but [$complaint] was unresolvable.

Any help is much appreciated!
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

How to link to a resource from a repeater entry?
FilamentFFilament / ❓┊help
3y ago
Database Notification open Resource modal action
FilamentFFilament / ❓┊help
8mo ago
Database Notification
FilamentFFilament / ❓┊help
3y ago
database notification
FilamentFFilament / ❓┊help
3y ago