Pass arguments to `DeleteAction` in Livewire component

Is it possible to add a DeleteAction to a component instead of a simple Action and pass arguments to it without overriding the action method? (https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#passing-action-arguments)

Here is some sample code (that doesn't work)

@foreach($this->messages as $message)
  {{ $this->deleteMessage($message->id) }} <-- I want something like this
@endforeach


// MyComponent.php
    public function deleteMessage(): Action
    {
        return DeleteAction::make('deleteMessage'); // This won't work as it needs a record
    }


I can do something like

->action(fn(array $arguments) => Message::find($arguments['message_id'])?->delete()))


But that kind of defeats the purpose of using a DeleteAction in the 1st place.

I tried a couple of things like

{{ ($this->deleteMessage)->record($message) }}
or
{{ ($this->deleteMessage($message->id) }}
...
//
public function deleteMessage($message_id): Action
{
  $message = Message::find($message_id);
  return DeleteAction::make('deleteMessage')
      ->record($message);
}

but nothing seems to work.

Any tips/ideas? Am I missing something?
Was this page helpful?