Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kramsuiluj's avatar

How do you create an Admin User or User with additional authorization?

I just started learning the Authorization part of laravel and I keep wondering how can I make an Admin User at least I want to know the first few steps how to do it.

So I saw this part of the documentation:

Gate::define('edit-settings', function (User $user) {
    return $user->isAdmin
                ? Response::allow()
                : Response::deny('You must be an administrator.');
});

My understanding of this is, there is a function in the user model that has name of "isAdmin" and the gate checks if it is true or false.

What I wanted to know is how does the "isAdmin" function work? Is there a table column in the users table that defines if a user is an admin or not? So the "isAdmin" function just checks what is indicated on that column? Is that how it basically work? Or is there a bettery way to do it?

0 likes
2 replies
bobbybouwmann's avatar
Level 88

Yeah, the basic idea is that you either add a method to model or you add a column to the table which you use to determine if the user is an admin or not.

In this case, Laravel uses isAdmin which can refer to the is_admin column on your users' table.

1 like

Please or to participate in this conversation.