GetTabs actions
In a scenario where I'm using soft deletes I have an active and inactive tab but my bulk archive (delete) action shows on both active and inactive header.
Is there a way to only show the archive (delete) action on the active tab?
7 Replies
'archive' => Tab::make(__('Archive'))
->modifyQueryUsing(function ($query) {
return $query->onlyTrashed();
})
Thanks @Spoof444 but that creates the tab? I already have two tabs but the bulk action "Archive" appears on both tabs when it does nothing on the inactive tab because the items are already archived.
if you have in your model use Softdeletes, that shouldnt all be neccesary, then you could use:
public function getTabs(): array
{
return [
'active' => Tab::make()
//this should now show the correct unfilters results
'inactive' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->onlyTrashed(),
];
}
Thanks for the tip @Spoof444 but that doesn't solve the issue I want to solve.
I want different bulk actions in each tab
For example there is no need to have the "Archive" action/button in the header of the inactive tab.
Solution
This should work
Ah didnt understand you correctly @harps . Dennis example looks perfect for you π
Thanks @Dennis Koch that was it.