kgalanos / filament-user
Add option to filamentphp to login with username or email
Requires
- php: ^8.1
- alperenersoy/filament-export: *
- bezhansalleh/filament-shield: *
- filament/filament: ^3.0
- illuminate/contracts: ^10.0
- laravel/sanctum: ^3.2
- spatie/laravel-package-tools: ^1.14.0
- spatie/laravel-permission: ^5.8
- stechstudio/filament-impersonate: ^3.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- roave/security-advisories: dev-latest
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-11-09 11:37:09 UTC
README
Add fields ulid(do not remove id),username,phone and phone_verified_at to User Model and you may login with username/email in filamentphp panel. Also installs and configure
"alperenersoy/filament-export": "*", "stechstudio/filament-impersonate": "^3.0", "bezhansalleh/filament-shield": "*"
Installation
You can install the package via composer:
composer require kgalanos/filament-user
You can publish and run the migrations with:
php artisan vendor:publish --tag="filament-user-migrations"
php artisan migrate
You can update Model User in config\auth.php with:
'model' => \Kgalanos\FilamentUser\Models\User::class,
or you can update
App\Models\User with class User extends \Kgalanos\FilamentUser\Models\User implements FilamentUser { use HasFilamentShield, HasRoles; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'name', 'email', 'password', 'username', 'avatar_url', 'phone', ]; ..... }
Install the Filament Panel Builder by running
php artisan filament:install --panels
You can update App\Providers\Filament\AdminPanelProvider with:
->login(\Kgalanos\FilamentUser\Filament\Pages\Auth\Login::class) ->registration(\Kgalanos\FilamentUser\Filament\Pages\Auth\Register::class) ->passwordReset() ->profile(\Kgalanos\FilamentUser\Filament\Pages\Auth\EditProfile::class) ->discoverPages(base_path('vendor/kgalanos/filament-user/src/Filament/Pages'),'Kgalanos\\FilamentUser\\Filament\\Pages')
You can publish the config file with:
php artisan vendor:publish --tag=filament-shield-config
php artisan vendor:publish --tag="filament-user-config"
This is the contents of the published config file:
return [
];
For the Shield
public function panel(Panel $panel): Panel { return $panel ->plugins([ \BezhanSalleh\FilamentShield\FilamentShieldPlugin::make() ]); }
php artisan shield:install
If there is no user id DB it ask you to create an admin.
php artisan make:filament-resource User
change the App\Filament\Resources
class UserResource extends \Kgalanos\FilamentUser\Filament\Resources\UserResource { protected static ?string $model = App\Models\User::class; public static function form(Form $form): Form { $form= parent::form($form); return $form; } public static function table(Table $table): Table { $table=parent::table($table); return $table; } }
Optionally you can use Kgalanos\FilamentUser\Filament\Widgets\ApplicationInfoWidget update App\Providers\Filament\AdminPanelProvider with:
->widgets([ Widgets\AccountWidget::class, // Widgets\FilamentInfoWidget::class, ApplicationInfoWidget::class, ])
Optionally, you can publish the views,if you use ApplicationInfoWidget::class you have to publish the views
using
php artisan vendor:publish --tag="filament-user-views"
Usage
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.