Manage your users with a highly customizable user resource for FilamentPHP with integration of filament-shield and filament-impersonate.
for filament v2 please use this repo
composer require tomatophp/filament-users
finally register the plugin on /app/Providers/Filament/AdminPanelProvider.php
->plugin(\TomatoPHP\FilamentUsers\FilamentUsersPlugin::make())
you can use the shield to protect your resource and allow user roles by install it first
composer require bezhansalleh/filament-shield
Add the Spatie\Permission\Traits\HasRoles trait to your User model(s):
use Illuminate\Foundation\Auth\User as Authenticatable;use Spatie\Permission\Traits\HasRoles;Â class User extends Authenticatable{ use HasRoles;Â // ...}
Publish the config file then setup your configuration:
->plugin(\BezhanSalleh\FilamentShield\FilamentShieldPlugin::make())
Now run the following command to install shield:
php artisan shield:install
Now we can publish the package assets.
php artisan vendor:publish --tag="filament-users-config"
now on your filament-users.php
config allow shield
/* * User Filament Shield */"shield" => true,
now clear your config
php artisan config:cache
for more information check the Filament Shield
you can use the impersonate to impersonate the user by install it first
composer require stechstudio/filament-impersonate
now on your filament-users.php
config allow shield
/* * User Filament Impersonate */"impersonate" => true,
now clear your config
php artisan config:cache
for more information check the Filament Impersonate
you can use the Laravel Jetstream Teams by install it first
composer require laravel/jetstream
now you need to install the jetstream with livewire
php artisan jetstream:install livewire
go to jetstream.php
and allow teams feature
'features' => [// Features::termsAndPrivacyPolicy(),// Features::profilePhotos(),// Features::api(), Features::teams(['invitations' => true]),// Features::accountDeletion(),],
now you need to publish teams migration from jetstream
php artisan vendor:publish --tag=jetstream-teams-migrations
now you need to migrate the teams migration
php artisan migrate
now on your filament-users.php
config allow shield
/* * User Filament Teams */"teams" => true,
now clear your config
php artisan config:cache
you can publish the resource to your project
php artisan filament-users:publish
it will publish the resource to your project
than go to filament-users.php
config file and change the publish_resource
to true
you can register the user relation manager to your project
use TomatoPHP\FilamentUsers\Facades\FilamentUser;Â public function boot(){ FilamentUser::register([ \Filament\Resources\RelationManagers\RelationManager::make() // Replace with your custom relation manager ]);}
we have add a lot of hooks to make it easy to attach actions, columns, filters, etc
use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserTable;Â public function boot(){ UserTable::register([ \Filament\Tables\Columns\TextColumn::make('something') ]);}
use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserActions;Â public function boot(){ UserActions::register([ \Filament\Tables\Actions\ReplicateAction::make() ]);}
use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserFilters;Â public function boot(){ UserFilters::register([ \Filament\Tables\Filters\SelectFilter::make('something') ]);}
use TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserBulkActions;Â public function boot(){ UserBulkActions::register([ \Filament\Tables\BulkActions\DeleteAction::make() ]);}
use TomatoPHP\FilamentUsers\Resources\UserResource\Form\UserForm;Â public function boot(){ UserForm::register([ \Filament\Forms\Components\TextInput::make('something') ]);}
use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ManageUserActions;use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\EditPageActions;use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ViewPageActions;use TomatoPHP\FilamentUsers\Resources\UserResource\Actions\CreatePageActions;Â public function boot(){ ManageUserActions::register([ Filament\Actions\Action::make('action') ]);Â EditPageActions::register([ Filament\Actions\Action::make('action') ]);Â ViewPageActions::register([ Filament\Actions\Action::make('action') ]);Â CreatePageActions::register([ Filament\Actions\Action::make('action') ]);}
use TomatoPHP\FilamentUsers\Resources\UserResource\Infolist\UserInfolist;Â public function boot(){ UserInfolist::register([ \Filament\Infolists\Components\TextEntry::make('something') ]);}
you can customize all resource classes to be any class you want with the same return from the config file
/** * --------------------------------------------- * Resource Building * --------------------------------------------- * if you want to use the resource custom class */'resource' => [ 'table' => [ 'class' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserTable::class, 'filters' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserFilters::class, 'actions' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserActions::class, 'bulkActions' => \TomatoPHP\FilamentUsers\Resources\UserResource\Table\UserBulkActions::class, ], 'form' => [ 'class' => \TomatoPHP\FilamentUsers\Resources\UserResource\Form\UserForm::class ], 'infolist' => [ 'class' => \TomatoPHP\FilamentUsers\Resources\UserResource\InfoList\UserInfoList::class ], 'pages' => [ 'list' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ManageUserActions::class, 'create' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\CreatePageActions::class, 'edit' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\EditPageActions::class, 'view' => \TomatoPHP\FilamentUsers\Resources\UserResource\Actions\ViewPageActions::class ]]
you can use the simple user resource by change on config, on your filament-users.php
config allow simple
/** * --------------------------------------------- * Use Simple Resource * --------------------------------------------- * change the resource from pages to modals by allow simple resource. */'simple' => true,
you can publish config file by use this command
php artisan vendor:publish --tag="filament-users-config"
you can publish languages file by use this command
php artisan vendor:publish --tag="filament-users-lang"
if you like to run PEST
testing just use this command
composer test
if you like to fix the code style just use this command
composer format
if you like to check the code by PHPStan
just use this command
composer analyse
Checkout our Awesome TomatoPHP