Exemplo n.º 1
0
 /**
  * [userMatrix description]
  * @return Response
  */
 public function showUserMatrix()
 {
     if (Shinobi::can(config('watchtower.acl.user.viewmatrix', false))) {
         $roles = Role::all();
         $users = $this->model::orderBy('name')->get();
         $us = DB::table('role_user')->select('role_id as r_id', 'user_id as u_id')->get();
         $pivot = [];
         foreach ($us as $u) {
             $pivot[] = $u->r_id . ":" . $u->u_id;
         }
         return view(config('watchtower.views.users.usermatrix'), compact('roles', 'users', 'pivot'));
     }
     return view(config('watchtower.views.layouts.unauthorized'), ['message' => 'sync user roles']);
 }
Exemplo n.º 2
0
 /**
  * Show the form for editing the permission roles.
  *
  * @param  int  $id
  * @return Response
  */
 public function editRole($id)
 {
     if (Shinobi::can(config('watchtower.acl.permission.role', false))) {
         $permission = Permission::findOrFail($id);
         $roles = $permission->roles;
         $available_roles = Role::whereDoesntHave('permissions', function ($query) use($id) {
             $query->where('permission_id', $id);
         })->get();
         return view(config('watchtower.views.permissions.role'), compact('permission', 'roles', 'available_roles'));
     }
     return view(config('watchtower.views.layouts.unauthorized'), ['message' => 'sync permission roles']);
 }
Exemplo n.º 3
0
 /**
  * A full matrix of roles and permissions.
  * @return Response
  */
 public function showRoleMatrix()
 {
     if (Shinobi::can(config('watchtower.acl.role.viewmatrix', false))) {
         $roles = Role::all();
         $perms = Permission::all();
         $prs = DB::table('permission_role')->select('role_id as r_id', 'permission_id as p_id')->get();
         $pivot = [];
         foreach ($prs as $p) {
             $pivot[] = $p->r_id . ":" . $p->p_id;
         }
         return view(config('watchtower.views.roles.rolematrix'), compact('roles', 'perms', 'pivot'));
     }
     return view(config('watchtower.views.layouts.unauthorized'), ['message' => 'view the role matrix']);
 }