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

How to use with multiple panel? #480

Open
iRaziul opened this issue Jan 3, 2025 · 1 comment
Open

How to use with multiple panel? #480

iRaziul opened this issue Jan 3, 2025 · 1 comment
Assignees

Comments

@iRaziul
Copy link
Contributor

iRaziul commented Jan 3, 2025

I was trying to use shield on a project where I have multiple panels with different guards (admin, web).

I could not use it on multiple panels and wanted to know if shield has the support for multiple panels.

@GertTimmerman
Copy link

What I have done is to make a 'fake' FilamentResource with custom permissions. In the canAccessPanel method in the User model you can check the permission. But bear in mind that you have to make a role just for one panel, so, for example, make a role 'Account Manager - Finance' and 'Account Manager - Order'.

class PanelResource extends Resource implements HasShieldPermissions
{
    protected static bool $shouldRegisterNavigation = false;

    // Add here all the panels 
    public static function getPermissionPrefixes(): array
    {
        return [
            'view_finance',
            'view_order'
        ];
    }
}
public function canAccessPanel(Panel $panel): bool
{
        return $this->can("view_{$panel->getId()}_panel");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants