This is a plugin for Filament v4
You can install the package via composer:
composer require deldius/filament-user-field
You can publish the config file with:
php artisan vendor:publish --tag="filament-user-field-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="filament-user-field-views"
This is the contents of the published config file:
return [ 'user_model' => [ 'class' => \App\Models\User::class, // Default user model 'fields' => [ 'id' => 'id', // Default user model ID field 'avatar_url' => 'avatar_url', // Default user model avatar field 'heading' => 'name', // Default user model name field 'description' => 'email', // Default user model email field ], ], 'active_state' => [ 'show' => false, // Show active state by default 'field' => 'is_active', // Default field for active state ],];
Display user information in a Filament table column:
use Deldius\UserField\UserColumn;use Filament\Support\Enums\Size;Â UserColumn::make('user_id') ->showActiveState() // Show active/inactive indicator ->size(Size::Small) // Set avatar size ->label('User') // Column label
Add UserColumn
to your Filament table columns:
public static function configure(Table $table): Table{ return [ UserColumn::make('user_id'), // ...other columns ];}
All available options:
use Deldius\UserField\UserColumn;use Filament\Support\Enums\Size;Â UserColumn::make('user_id') ->showActiveState(true) // Show active/inactive indicator ->isActiveState(fn($user) => $user->is_active) // Custom active state logic ->showAvatar(true) // Show avatar ->avatarUrl(fn($user) => $user->avatar_url) // Custom avatar URL ->size(Size::Small) // Set avatar size ->heading(fn($user) => $user->name) // Custom heading ->description(fn($user) => $user->email) // Custom description ->emptyState(view('empty')) // Custom empty state view ->emptyStateHeading('No user') // Custom empty state heading ->emptyStateDescription('No user found') // Custom empty state description ->label('User') // Column label
Add UserColumn
to your Filament table columns:
public static function configure(Table $table): Table{ return [ UserColumn::make('user_id'), // ...other columns ];}
Display user information in a Filament infolist entry:
use Deldius\UserField\UserEntry;use Filament\Support\Enums\Size;Â UserEntry::make('user_id') ->showActiveState() // Show active/inactive indicator ->size(Size::Small) // Set avatar size ->label('User') // Entry label
Add UserEntry
to your Filament infolist schema:
public static function configure(Schema $schema): Schema{ return [ UserEntry::make('user_id'), // ...other items ];}
Display user information in a Filament infolist entry. All available options:
use Deldius\UserField\UserEntry;use Filament\Support\Enums\Size;Â UserEntry::make('user_id') ->showActiveState(true) // Show active/inactive indicator ->isActiveState(fn($user) => $user->is_active) // Custom active state logic ->showAvatar(true) // Show avatar ->avatarUrl(fn($user) => $user->avatar_url) // Custom avatar URL ->size(Size::Small) // Set avatar size ->heading(fn($user) => $user->name) // Custom heading ->description(fn($user) => $user->email) // Custom description ->emptyState(view('empty')) // Custom empty state view ->emptyStateHeading('No user') // Custom empty state heading ->emptyStateDescription('No user found') // Custom empty state description ->label('User') // Entry label
Add UserEntry
to your Filament infolist schema:
public static function configure(Schema $schema): Schema{ return [ UserEntry::make('user_id'), // ...other items ];}
Planned feature: UserSelect support for Filament Form is in development and will be added in a future release.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.
Trung Dao is a passionate coder with a strong affinity for Laravel stacks, dedicating over 8 years to mastering and building with the framework. Always eager to learn and share knowledge, Trung enjoys exploring new technologies and contributing to the developer community.