|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Filament\Admin\Resources\Users\Pages; |
| 4 | + |
| 5 | +use App\Filament\Admin\Resources\Users\UserResource; |
| 6 | +use Filament\Actions\EditAction; |
| 7 | +use Filament\Resources\Pages\ViewRecord; |
| 8 | +use Filament\Infolists\Infolist; |
| 9 | +use Filament\Infolists\Components\TextEntry; |
| 10 | +use Filament\Infolists\Components\ImageEntry; |
| 11 | +use Filament\Infolists\Components\IconEntry; |
| 12 | +use Filament\Schemas\Components\Section; |
| 13 | +use Filament\Schemas\Schema; |
| 14 | + |
| 15 | +class ViewUser extends ViewRecord |
| 16 | +{ |
| 17 | + protected static string $resource = UserResource::class; |
| 18 | + |
| 19 | + protected function getHeaderActions(): array |
| 20 | + { |
| 21 | + return [ |
| 22 | + EditAction::make(), |
| 23 | + ]; |
| 24 | + } |
| 25 | + |
| 26 | + public function infolist(Schema $schema): Schema |
| 27 | + { |
| 28 | + return $schema |
| 29 | + ->components([ |
| 30 | + Section::make('User Profile') |
| 31 | + ->columns(2) |
| 32 | + ->schema([ |
| 33 | + ImageEntry::make('profile_photo_url') |
| 34 | + ->label('Profile Photo') |
| 35 | + ->circular() |
| 36 | + ->defaultImageUrl(fn ($record) => 'https://ui-avatars.com/api/?name=' . urlencode($record->name) . '&color=7F9CF5&background=EBF4FF') |
| 37 | + ->columnSpanFull(), |
| 38 | + |
| 39 | + TextEntry::make('name') |
| 40 | + ->label('Full Name') |
| 41 | + ->size('lg') |
| 42 | + ->weight('bold'), |
| 43 | + |
| 44 | + TextEntry::make('email') |
| 45 | + ->label('Email Address') |
| 46 | + ->copyable() |
| 47 | + ->icon('heroicon-o-envelope'), |
| 48 | + |
| 49 | + IconEntry::make('email_verified_at') |
| 50 | + ->label('Email Verified') |
| 51 | + ->boolean() |
| 52 | + ->trueIcon('heroicon-o-check-badge') |
| 53 | + ->falseIcon('heroicon-o-x-circle') |
| 54 | + ->trueColor('success') |
| 55 | + ->falseColor('danger'), |
| 56 | + |
| 57 | + TextEntry::make('email_verified_at') |
| 58 | + ->label('Verified At') |
| 59 | + ->dateTime('M d, Y H:i') |
| 60 | + ->placeholder('Not verified'), |
| 61 | + ]), |
| 62 | + |
| 63 | + Section::make('Roles & Permissions') |
| 64 | + ->columns(2) |
| 65 | + ->schema([ |
| 66 | + TextEntry::make('roles.name') |
| 67 | + ->label('Assigned Roles') |
| 68 | + ->badge() |
| 69 | + ->color('success') |
| 70 | + ->formatStateUsing(fn ($state) => ucfirst($state)) |
| 71 | + ->placeholder('No roles assigned') |
| 72 | + ->columnSpanFull(), |
| 73 | + |
| 74 | + TextEntry::make('permissions.name') |
| 75 | + ->label('Direct Permissions') |
| 76 | + ->badge() |
| 77 | + ->color('info') |
| 78 | + ->placeholder('No direct permissions') |
| 79 | + ->columnSpanFull(), |
| 80 | + ]), |
| 81 | + |
| 82 | + Section::make('Team Information') |
| 83 | + ->columns(2) |
| 84 | + ->schema([ |
| 85 | + TextEntry::make('teams.name') |
| 86 | + ->label('Teams') |
| 87 | + ->badge() |
| 88 | + ->color('primary') |
| 89 | + ->placeholder('No teams') |
| 90 | + ->columnSpanFull(), |
| 91 | + |
| 92 | + TextEntry::make('currentTeam.name') |
| 93 | + ->label('Current Team') |
| 94 | + ->placeholder('No current team'), |
| 95 | + |
| 96 | + TextEntry::make('ownedTeams.name') |
| 97 | + ->label('Owned Teams') |
| 98 | + ->badge() |
| 99 | + ->color('warning') |
| 100 | + ->placeholder('No owned teams'), |
| 101 | + ]), |
| 102 | + |
| 103 | + Section::make('Account Information') |
| 104 | + ->columns(2) |
| 105 | + ->schema([ |
| 106 | + TextEntry::make('created_at') |
| 107 | + ->label('Account Created') |
| 108 | + ->dateTime('M d, Y H:i') |
| 109 | + ->icon('heroicon-o-calendar'), |
| 110 | + |
| 111 | + TextEntry::make('updated_at') |
| 112 | + ->label('Last Updated') |
| 113 | + ->dateTime('M d, Y H:i') |
| 114 | + ->since() |
| 115 | + ->icon('heroicon-o-clock'), |
| 116 | + |
| 117 | + TextEntry::make('two_factor_confirmed_at') |
| 118 | + ->label('Two-Factor Enabled') |
| 119 | + ->formatStateUsing(fn ($state) => $state ? 'Yes' : 'No') |
| 120 | + ->badge() |
| 121 | + ->color(fn ($state) => $state ? 'success' : 'gray'), |
| 122 | + |
| 123 | + TextEntry::make('profile_photo_path') |
| 124 | + ->label('Profile Photo Path') |
| 125 | + ->placeholder('No custom photo') |
| 126 | + ->limit(50), |
| 127 | + ]), |
| 128 | + ]); |
| 129 | + } |
| 130 | +} |
0 commit comments