PHP code example of zpmlabs / filament-popup

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

    

zpmlabs / filament-popup example snippets


use ZPMLabs\FilamentPopup\Enums\PopUpPosition;

TextColumn::make('name')
    ->badge()
    ->popup(UserPopupInfolist::class, PopUpPosition::TopCenter)
    ->searchable();

ZPMLabs\FilamentPopup\FilamentPopupServiceProvider::class,

TextColumn::make('name')
    ->popup(UserPopupInfolist::class, PopUpPosition::TopCenter, [
        'width' => 'md',
        'delay' => 250,
        'closeDelay' => 300,
        'offset' => 10,
        'interactive' => true,
        'trigger' => 'hover',
    ]);

TextColumn::make('name')
    ->popup(UserPopupInfolist::class)
    ->popupPosition(PopUpPosition::TopCenter)
    ->popupWidth('md')
    ->popupDelay(300)
    ->popupCloseDelay(300)
    ->popupTrigger('hover', key: 'shift');

TextColumn::make('name')
    ->label('Hover')
    ->badge()
    ->popup($content, PopUpPosition::TopCenter, [
        'width' => 'md',
        'trigger' => 'hover',
    ]);

TextColumn::make('email')
    ->label('Click')
    ->copyable()
    ->popup($content, PopUpPosition::MiddleRight, [
        'width' => 'lg',
        'trigger' => 'click',
    ]);

IconColumn::make('email_verified_at')
    ->label('Right click')
    ->boolean()
    ->popup($content, PopUpPosition::BottomCenter, [
        'trigger' => 'contextmenu',
    ]);

TextColumn::make('created_at')
    ->label('Shift hover')
    ->dateTime()
    ->popup($content, PopUpPosition::MiddleLeft, [
        'width' => 'xl',
        'trigger' => 'hover',
        'triggerKey' => 'shift',
    ]);

TextColumn::make('name')
    ->popup(fn ($record) => [
        'Name' => $record->name,
        'Email' => $record->email,
        'Joined' => $record->created_at?->toFormattedDateString(),
    ]);

use Filament\Infolists\Components\IconEntry;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Schema;

final class UserPopupInfolist
{
    public static function make(Schema $schema, mixed $record): Schema
    {
        return $schema
            ->record($record)
            ->components([
                Grid::make(2)
                    ->schema([
                        TextEntry::make('name'),
                        TextEntry::make('email'),
                        IconEntry::make('email_verified_at')
                            ->label('Verified')
                            ->boolean(),
                    ]),
            ]);
    }
}

TextColumn::make('name')
    ->popup(UserPopupInfolist::class);

use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Actions;
use Filament\Schemas\Components\Form;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Schema;

final class UserPopupForm
{
    public static function make(Schema $schema, mixed $record): Schema
    {
        return $schema
            ->record($record)
            ->statePath('popupFormData')
            ->components([
                Form::make([
                    Grid::make(2)
                        ->schema([
                            TextInput::make('name')
                                ->                                ->label('Save user')
                                ->action('save'),
                        ])
                            ->alignEnd(),
                    ])
                    ->columnSpanFull(),
            ]);
    }
}

Action::make('savePopupForm')->action('save');
Action::make('cancelPopupForm')->action('close');

TextColumn::make('name')
    ->popup('filament-popup::examples.user-popup');

$record
$options

TextColumn::make('name')
    ->popup(UserPopupComponent::class);

public function __construct(
    public mixed $record,
    public array $options = [],
) {}

use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

final class UserPopupPreviewTable
{
    public static function configure(Table $table, mixed $record): Table
    {
        return $table
            ->records(fn (): array => [
                1 => [
                    'title' => 'First item',
                    'slug' => 'first-item',
                    'is_featured' => true,
                ],
                2 => [
                    'title' => 'Second item',
                    'slug' => 'second-item',
                    'is_featured' => false,
                ],
            ])
            ->columns([
                TextColumn::make('title'),
                TextColumn::make('slug'),
                IconColumn::make('is_featured')
                    ->boolean(),
            ]);
    }
}

TextColumn::make('name')
    ->popup(UserPopupPreviewTable::class);

use ZPMLabs\FilamentPopup\Examples\UserResource;

public function panel(Panel $panel): Panel
{
    return $panel
        ->resources([
            UserResource::class,
        ]);
}

return [
    'default_width' => 'sm',
    'default_delay' => 250,
    'default_close_delay' => 200,
    'default_offset' => 8,
    'default_position' => 'top-center',
    'default_trigger' => 'hover',
    'default_trigger_key' => null,
    'default_show_actions' => false,
    'default_save_label' => 'Save',
    'default_cancel_label' => 'Cancel',
];
bash
php artisan vendor:publish --tag=filament-popup-config
bash
php artisan filament:assets
bash
php artisan filament:assets
php artisan optimize:clear