PHP code example of yieldstudio / filament-panel

1. Go to this page and download the library: Download yieldstudio/filament-panel 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/ */

    

yieldstudio / filament-panel example snippets


use YieldStudio\FilamentPanel\Plugins\YieldPanel;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            YieldPanel::make()
                ->withSuggestedColors()    // Apply YieldStudio color palette
                ->withSuggestedFont()       // Use Inter font
                ->withSuggestedIcons()      // Use Phosphor icons
        );
}

use YieldStudio\FilamentPanel\Plugins\EnvironmentIndicator;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            EnvironmentIndicator::make()
                ->visible(fn () => auth()->user()?->hasRole('super_admin'))
                ->showBadge(fn (): bool => !app()->environment('production'))
                ->color(fn (): array => match (app()->environment()) {
                    'production' => Color::Red,
                    'staging' => Color::Orange,
                    'development' => Color::Blue,
                    default => Color::Gray,
                })
                ->badgePosition(PanelsRenderHook::GLOBAL_SEARCH_BEFORE)
        );
}

use YieldStudio\FilamentPanel\Plugins\DevelopperLogin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugin(
            DevelopperLogin::make()
                ->enabled(fn () => app()->isLocal())
                ->users([
                    'Admin User' => '[email protected]',
                    'Regular User' => '[email protected]',
                ])
                ->modelClass(\App\Models\User::class)
        );
}

use YieldStudio\FilamentPanel\Actions\CopyAction;

// In a table
public static function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('id'),
            TextColumn::make('email'),
        ])
        ->actions([
            CopyAction::make()
                ->copyable(fn ($record) => $record->email),
        ]);
}

// In a form or infolist
CopyAction::make()
    ->copyable(fn ($record) => $record->api_key)
    ->successNotificationTitle('API Key copied!')

use YieldStudio\FilamentPanel\Tables\Columns\ProgressBarColumn;

public static function table(Table $table): Table
{
    return $table
        ->columns([
            ProgressBarColumn::make('stock')
                ->maxValue(100)
                ->lowThreshold(20)
                ->dangerColor('rgb(244, 63, 94)')
                ->warningColor('rgb(251, 146, 60)')
                ->successColor('rgb(34, 197, 94)')
                ->dangerLabel(fn ($state) => $state <= 0 ? 'Out of stock' : $state)
                ->warningLabel(fn ($state) => $state . ' - Low stock')
                ->successLabel(fn ($state) => $state . ' - In stock'),
        ]);
}
bash
composer analyse