F
Filamentβ€’10mo 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β€’10mo ago
Easiest would be via canAccessPanel() method on the User model that you need to implement anyway
ocram82
ocram82β€’10mo 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 tonystark@marvel.com can access AdminPanel and the other users can access the AppPanel....how can i write this?
Dennis Koch
Dennis Kochβ€’10mo ago
I think you get the panel id (app, admin) with $panel->getId() and can return your condition based on that.
ocram82
ocram82β€’10mo ago
wow thanks a lot! I could not find that function in the docs....thanks again
blakdronzer
blakdronzerβ€’10mo 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β€’10mo 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
ocram82β€’10mo 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!