Adding a custom action component through a ViewColumn

I've created a action component in which I have included a method :
public function joinAction(): Action
{
return Action::make('join')
->requiresConfirmation()
->action(function () {
dd('foo');
});
}
public function joinAction(): Action
{
return Action::make('join')
->requiresConfirmation()
->action(function () {
dd('foo');
});
}
And on the view (blade) file i'm using {{ $this->joinAction }} like:
<div>
{{ $this->joinAction }}

<x-filament-actions::modals/>
</div>
<div>
{{ $this->joinAction }}

<x-filament-actions::modals/>
</div>
But i'm still getting an error that Property [$joinAction] not found on component: What would be the correct setup to achieve this?
4 Replies
beautiful-angel
beautiful-angel5mo ago
hi i can help you DM
awcodes
awcodes5mo ago
Please off your help here so that the solutions can help others.
LeandroFerreira
LeandroFerreira5mo ago
use action() method in the ViewColumn:
Tables\Columns\ViewColumn::make('view_column')
->action(Tables\Actions\Action::make('myAction')
->requiresConfirmation()
->action(function (YourModel $record) {
dd($record);
})
)
->view('your-view-column')
Tables\Columns\ViewColumn::make('view_column')
->action(Tables\Actions\Action::make('myAction')
->requiresConfirmation()
->action(function (YourModel $record) {
dd($record);
})
)
->view('your-view-column')
<!-- resources/views/your-view-column.blade.php -->
<div>
@if($action = $getAction())
<x-filament::button
wire:click="mountTableAction('{{ $action->getName() }}', '{{ $recordKey }}')"
>
{{ $action->getLabel() }}
</x-filament::button>
@endif
</div>
<!-- resources/views/your-view-column.blade.php -->
<div>
@if($action = $getAction())
<x-filament::button
wire:click="mountTableAction('{{ $action->getName() }}', '{{ $recordKey }}')"
>
{{ $action->getLabel() }}
</x-filament::button>
@endif
</div>
Amiejah
AmiejahOP5mo ago
this works! awesome I could create a custom action and add it this way thanks

Did you find this page helpful?