© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
MRBUG

if user is admin

i want a functionallity where i want that if user is admin = 1 it can go to dashbaord but if is admin is 0 than he can not access the admin panel currently i am using this functionallity which is give in filamentphp documentation and i created a code in user model like this

public function canAccessPanel(Panel $panel): bool
    {
        $user = User::where('email', $this->email)->first();

        if ($user && $user->is_admin === 1) {
            return true;
        }
        return false;
    }
public function canAccessPanel(Panel $panel): bool
    {
        $user = User::where('email', $this->email)->first();

        if ($user && $user->is_admin === 1) {
            return true;
        }
        return false;
    }


but i also got this given image.
But i want that if i can not access the admin panel it will show error in the login page and i want a error message like "you are not admin" i dont want given image result how can i archive this functionallity with custom error message if is_admin=0 this will show in admin page like "this email address is not admin /or somthing other custom error message insted of 403 forbidden message"
Screenshot_from_2023-09-06_14-53-42.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Login auth check if user is admin
FilamentFFilament / ❓┊help
17mo ago
Show Icon tenant If user Is_admin
FilamentFFilament / ❓┊help
3y ago
Skip Registration Team if user is an admin?
FilamentFFilament / ❓┊help
2y ago
auth()->user()->is_admin inside AdminPanel Provider return null
FilamentFFilament / ❓┊help
2y ago