deldius / filament-user-field
Utility fields for User: Entry, Input, Column
Fund package maintenance!
Deldius
Requires
- php: ^8.2
- filament/filament: ^4.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^8
- nunomaduro/larastan: ^3.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^3
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
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' => \App\Models\User::class, // Default user model 'user_model_id' => 'id', // Default user model ID field 'show_active_state' => false, // Show active state by default 'user_model_is_active' => 'is_active', // Default user model Is Active field 'user_model_avatar' => 'avatar_url', // Default user model name field 'user_model_heading' => 'name', // Default user model heading field 'user_model_description' => 'email', // Default user model description field ];
Usage
UserColumn (for Filament Tables)
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 ]; }
UserEntry (for Filament Infolists)
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 ]; }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.