Access to panel
Hi,
How can I set a condition (based on user role for example) to deny users to access to a specific panel? thanks š without using a middleware
21 Replies
Thanks for answer, unfortunately this is for all panels, but I need for only panel X
Am I wrong ?
Yes, it's for all panels. There are other options to do it per-panel. It's on the same page in the docs.
Could you please share it with me, sorry I didn't get it :/
Let's backtrack a little bit, you have many panels, and you want to limit access for one specific pannel?
Yes, one or many ofc
I see, do you know what is an authentication guard š
lol, yes I got that wrong
hhh it's okey but really I appreciate your assistance š
1 sec
If you want to go with
canAccessPanel()
, you can check the current panel with filament()->getCurrentPanel()
Yes there's a solution but not nice for me, use that function and set a loop or may be a switch
Ok, it sounds like you know what you're doing. I'll be curious to know your solution when you have it, if you want to share it.
What I hope to see is a function on Panel, something like this ->canAccess(bool)
š
Waiting for a filament member to assist us
Curious about this too, different panels and different user role access would be great! š
I use a Middleware
And then added it to the middleware() on the panel.
public function canAccessPanel(Panel $panel): bool
{
if ($panel->isDefault()) {
return $this->is_admin;
} else {
return true;
}
}
what about this? and have the admin(main one as default)? would it be a light check? rather than a middleware?
this won't really help on multiple pannels, but I saw in the ServiceProvider that it has a default methodThanks, and yes I've already made it like that
so probably the Middleware is the best and the easiest to do
thanks
in the model ^
This is probably the cleanest if you have the admin middleware