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 PatronumOP9mo ago
Anyone ?
Dennis Koch
Dennis Koch9mo ago
You want a table header action and just query all your models.
Expecto Patronum
Expecto PatronumOP9mo ago
No description
No description
No description
Expecto Patronum
Expecto PatronumOP9mo 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
dissto9mo ago
You want a table header action and just query all your models.
Expecto Patronum
Expecto PatronumOP9mo ago
So i just move my code into header action and change bulkaction to normal action?
dissto
dissto9mo 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 PatronumOP9mo ago
I forgot to mentioned . This code in relation manager table So i want to capture all record from relation manager table
dissto
dissto9mo ago
Well, the relation manager also has ->headerActions on the $table 😋
Dennis Koch
Dennis Koch9mo ago
Then you probably need to filter with the owner record: ->action(fn ($livewire) => YourModel::where('related_id', $livewire->ownerRecord->id)->get()

Did you find this page helpful?