F
Filamentβ€’15mo ago
ocram82

Admin Panel and App Panel access

I've created the default admin panel and another AppPanel as ->default() how can i control the access to the panels? I want to allow only admin user to access admin panel and other users to access AppPanel. what's the simplest way to do it?
7 Replies
Dennis Koch
Dennis Kochβ€’15mo ago
Easiest would be via canAccessPanel() method on the User model that you need to implement anyway
ocram82
ocram82OPβ€’15mo ago
now i have this
public function canAccessPanel(Panel $panel): bool
{
return $this->email == $this->hasVerifiedEmail();
}
public function canAccessPanel(Panel $panel): bool
{
return $this->email == $this->hasVerifiedEmail();
}
I would like to control that a particulary user, for example the user with mail [email protected] can access AdminPanel and the other users can access the AppPanel....how can i write this?
Dennis Koch
Dennis Kochβ€’15mo ago
I think you get the panel id (app, admin) with $panel->getId() and can return your condition based on that.
ocram82
ocram82OPβ€’15mo ago
wow thanks a lot! I could not find that function in the docs....thanks again
blakdronzer
blakdronzerβ€’15mo ago
I agree more with you @ocram_82 - the application has become vast and the documentation shared / provided is far less. But can't really blame - the documentation drive itself is way too much to be covered up with all possible features / functionalities in place! its good to have this discord - a place where experienced people can share in their inputs with new commers like us πŸ™‚ Thank you very much @Filament team!! and experts around sharing their valuable knowledge and time!
Dennis Koch
Dennis Kochβ€’15mo ago
No need to document every method. The class is type hinted, you could easily open the file that contains Panel and see all the methods there are. Code diving is a skill that helps a lot in every project πŸ˜‰
ocram82
ocram82OPβ€’15mo ago
Yes, i cannot complain. Filament is an awsome tool, the community is fantastic and the team is super! I can only say thanks to all that help and contribute. Nothing can be perfect but the strive for continuous improvment is very apprecciable For sure! I'll try to improve this skill!
Want results from more Discord servers?
Add your server