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


return [
    'primary_count' => 1,
    'label' => 'More',
    'icon' => 'heroicon-m-ellipsis-horizontal',
    'color' => 'gray',
    'hidden_label' => false,
    'button' => true,
    'icon_position' => \Filament\Support\Enums\IconPosition::After, // right
    'filter_unauthorized' => false,
];

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();

FilamentHeaderActions::make($actions)
    ->primaryCount(int $count = 1)
    ->label(string $label = 'More')
    ->icon(string|\BackedEnum|null $icon = null)
    ->color(string $color = 'gray')
    ->hiddenLabel(bool $state = true)
    ->button(bool $state = true)
    ->iconPosition(\Filament\Support\Enums\IconPosition $position = \Filament\Support\Enums\IconPosition::After)
    ->filterUnauthorized(bool $state = true)
    ->toActions();
bash
php artisan vendor:publish --tag="filament-header-actions-config"