Support the ongoing development of Laravel.io →
Authentication
Last updated 1 year ago.
0

Take a look at these too packages:

https://cartalyst.com/manual/sentry

https://github.com/Zizaco/entrust

Both packages support user management including roles and you can assign them very easily, it's all in the documentation!

Last updated 1 year ago.
0

I am using Zizaco/entrust

After assigned a multiple roles for a single user. Table assigned_role

id user role_id 1 1 1 2 1 2 3 1 3 etc.,

Now I have the following code in login controller

 // Assign a Role to user 
            foreach (Auth::User()->roles as $key => $role) {
                $role_id = $role['role_id'];
            }
            Session::put('user_role', $role_id);

in layout menu show /hide purpose I am using

@if(Auth::user()->ability(Session::get('user_role'),'UsersController@index'))
// some links
@endif

when I logged in as Role 2 it doesn't have user access but still it displays the user menu for user role 2

I am not sure what I did wrong ?

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.