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;
});

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.

Any help is much appreciated!
Was this page helpful?