Run BulkAction Without Need to Select Record?

Is there possible to run BulkAction without need to select the record first? Means run bulk-action for all record in table by default
10 Replies
Expecto Patronum
Expecto Patronumβ€’2mo ago
Anyone ?
Dennis Koch
Dennis Kochβ€’2mo ago
You want a table header action and just query all your models.
Expecto Patronum
Expecto Patronumβ€’2mo ago
No description
No description
No description
Expecto Patronum
Expecto Patronumβ€’2mo ago
I already make this action Its working as i wanted . But i need to select record first in order to data appear in pdf after generated I want to set it will capture all data while generating without i need to select the record Is there any parameter i missing in my action?
dissto
disstoβ€’2mo ago
You want a table header action and just query all your models.
Expecto Patronum
Expecto Patronumβ€’2mo ago
So i just move my code into header action and change bulkaction to normal action?
dissto
disstoβ€’2mo ago
No, but something like this:
Action::make('myCoolAction')
->action(function(){
$records = MyModel::all();
....
})

Action::make('myCoolAction')
->action(function(){
$records = MyModel::all();
....
})

You would want to do that on your ListXXX.php in the getHeaderActions
Expecto Patronum
Expecto Patronumβ€’2mo ago
I forgot to mentioned . This code in relation manager table So i want to capture all record from relation manager table
dissto
disstoβ€’2mo ago
Well, the relation manager also has ->headerActions on the $table πŸ˜‹
Dennis Koch
Dennis Kochβ€’2mo ago
Then you probably need to filter with the owner record: ->action(fn ($livewire) => YourModel::where('related_id', $livewire->ownerRecord->id)->get()