PHP code example of harvirsidhu / filament-header-actions
1. Go to this page and download the library: Download harvirsidhu/filament-header-actions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
harvirsidhu / filament-header-actions example snippets
use Filament\Actions\Action;
use Harvirsidhu\FilamentHeaderActions\Facades\FilamentHeaderActions;
public function getHeaderActions(): array
{
$actions = [
Action::make('edit'),
Action::make('archive'),
Action::make('delete'),
];
return FilamentHeaderActions::make($actions)->toActions();
}
public function getHeaderActions(): array
{
$actions = [
Action::make('edit')->hidden(true), // ignored
Action::make('archive'), // kept
Action::make('delete')->visible(false), // ignored
Action::make('publish')->authorize('update', $this->record), // kept by default
];
// primary_count = 1:
// - first available action stays primary
// - remaining available actions go to More (or flatten if only one)
return FilamentHeaderActions::make($actions)->toActions();
}
return FilamentHeaderActions::make($actions)
->filterUnauthorized() // opt-in (default is false)
->toActions();