From 32052f219989fba495bb62d88a1b60b8ee0240d6 Mon Sep 17 00:00:00 2001 From: Zep Fietje Date: Fri, 6 Oct 2023 10:03:53 +0200 Subject: [PATCH] Update panel access docs --- packages/panels/docs/08-users.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/panels/docs/08-users.md b/packages/panels/docs/08-users.md index e38cf70982..08da038ffc 100644 --- a/packages/panels/docs/08-users.md +++ b/packages/panels/docs/08-users.md @@ -32,7 +32,31 @@ class User extends Authenticatable implements FilamentUser The `canAccessPanel()` method returns `true` or `false` depending on whether the user is allowed to access the `$panel`. In this example, we check if the user's email ends with `@yourdomain.com` and if they have verified their email address. -You also have access to the methods in the `$panel` object, so you could do conditional checks for separate panels using something like `if ($panel->getId() === 'foo') return true;` You can explore the Panel object for more options. +Since you have access to the current `$panel`, you can write conditional checks for separate panels. For example, only restricting access to the admin panel while allowing all users to access the other panels of your app: + +```php +getId() === 'admin') { + return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail() + } + + return true; + } +} +``` ## Setting up user avatars