|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace App\Filament\Resources\AuditLogs\Schemas; |
| 6 | + |
| 7 | +use Filament\Infolists\Components\TextEntry; |
| 8 | +use Filament\Schemas\Components\Section; |
| 9 | +use Filament\Schemas\Schema; |
| 10 | + |
| 11 | +class AuditLogInfolist |
| 12 | +{ |
| 13 | + public static function configure(Schema $schema): Schema |
| 14 | + { |
| 15 | + return $schema |
| 16 | + ->components([ |
| 17 | + Section::make('Audit Log Details') |
| 18 | + ->schema([ |
| 19 | + TextEntry::make('created_at') |
| 20 | + ->label('Timestamp') |
| 21 | + ->dateTime(), |
| 22 | + TextEntry::make('user.name') |
| 23 | + ->label('User') |
| 24 | + ->placeholder('System'), |
| 25 | + TextEntry::make('action') |
| 26 | + ->badge() |
| 27 | + ->color(fn (string $state): string => match ($state) { |
| 28 | + 'create' => 'success', |
| 29 | + 'update' => 'warning', |
| 30 | + 'delete' => 'danger', |
| 31 | + 'deploy' => 'info', |
| 32 | + 'prepare' => 'primary', |
| 33 | + 'create_zip' => 'secondary', |
| 34 | + default => 'secondary', |
| 35 | + }), |
| 36 | + TextEntry::make('model_type') |
| 37 | + ->label('Entity Type') |
| 38 | + ->formatStateUsing(fn (string $state): string => class_basename($state)), |
| 39 | + TextEntry::make('model_id') |
| 40 | + ->label('Entity ID'), |
| 41 | + TextEntry::make('ip_address') |
| 42 | + ->label('IP Address') |
| 43 | + ->placeholder('-'), |
| 44 | + TextEntry::make('user_agent') |
| 45 | + ->label('User Agent') |
| 46 | + ->placeholder('-') |
| 47 | + ->columnSpanFull(), |
| 48 | + ]), |
| 49 | + Section::make('Changes') |
| 50 | + ->schema([ |
| 51 | + TextEntry::make('old_values') |
| 52 | + ->label('Previous Values') |
| 53 | + ->placeholder('No previous values') |
| 54 | + ->formatStateUsing(fn ($state) => $state ? json_encode($state, JSON_PRETTY_PRINT) : null) |
| 55 | + ->columnSpanFull() |
| 56 | + ->copyable(), |
| 57 | + TextEntry::make('new_values') |
| 58 | + ->label('New Values') |
| 59 | + ->placeholder('No new values') |
| 60 | + ->formatStateUsing(fn ($state) => $state ? json_encode($state, JSON_PRETTY_PRINT) : null) |
| 61 | + ->columnSpanFull() |
| 62 | + ->copyable(), |
| 63 | + ]) |
| 64 | + ->collapsible() |
| 65 | + ->collapsed(), |
| 66 | + ]); |
| 67 | + } |
| 68 | +} |
0 commit comments