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!
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 ?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community