Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set up a custom users table #72

Merged
merged 6 commits into from
Mar 4, 2021
Merged

Conversation

danharrin
Copy link
Member

@danharrin danharrin commented Mar 4, 2021

This PR addresses #30, #67 and part of #58.

It introduces a new configuration option - filament.auth.guard - which can be set to the name of any guard in your app. The user model provided to that guard must implement Filament\Models\Contracts\FilamentUser and use the Filament\Models\Concerns\IsFilamentUser trait. You may specify a few properties on the custom model to tweak the default behaviour:

  • static $filamentAdminColumn can be set to the name of a column that dictates if the user is a Filament admin (superuser).
  • static $filamentAvatarColumn can be set to the name of a column that stores the path to the user's avatar.
  • static $filamentRolesColumn can be set to the name of a column that stores Filament roles. If none is provided, role functionality is disabled.
  • static $filamentUserColumn can be set to the name of a column that dictates if the user can access Filament or not.

These properties are accompanied by methods such as canAccessFilament() and isFilamentAdmin() that can be overwritten to customise the experience further.

Since the user model may now contain extra properties not present in the default UserResource, you may publish and customise it using php artisan vendor:publish --tag=filament-user-resource, and setting the filament.user_resource config to \App\Filament\Resources\UserResource::class.

@danharrin danharrin added the enhancement New feature or request label Mar 4, 2021
@danharrin danharrin requested a review from ryanscherler March 4, 2021 10:21
routes/web.php Outdated Show resolved Hide resolved
@danharrin danharrin merged commit a4ec37e into develop Mar 4, 2021
@danharrin danharrin deleted the custom-auth-guard branch March 4, 2021 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants