User Roles What should be the best way of managing 3 different users Permissions?
Admin = 0
Staff = 1
Registered User = 3
should I just create another column in the user table 'user_type' and then somehow restrict users to certain controller methods ?
Please suggest!
trying right now! thanks!
Since it's a one to one in this case you can get away with adding the role to the users table.
Then you can check for it like
if (Auth::user()->role == ADMIN) {
//Do some admin stuff
}
can we limit user access directly from routes (routes/web.php)
like one route only accessible by admin.
Yes, you can do this with a "Role" Middleware that takes the name/id of the role as a parameter, and checks that the user role's name/id matches the parameter.
https://laravel.com/docs/8.x/middleware
Please sign in or create an account to participate in this conversation.