예제 #1
0
 /**
  * get all permissions with rolewise access
  * @return array
  */
 public function get_all_permisssions()
 {
     $all_permissions = Permissions::all();
     $all_roles = Roles::all();
     $permission_matrix = array();
     foreach ($all_permissions as $permission) {
         $permission_matrix[$permission->group][$permission->pid]['permission'] = $permission;
         foreach ($all_roles as $role) {
             $permission_matrix[$permission->group][$permission->pid]['roles'][$role->rid]['role'] = $role;
             $role_permission_access = $role->role_permissions()->where('pid', '=', $permission->pid)->get();
             if (count($role_permission_access) > 0) {
                 $permission_matrix[$permission->group][$permission->pid]['roles'][$role->rid]['access'] = 1;
             } else {
                 $permission_matrix[$permission->group][$permission->pid]['roles'][$role->rid]['access'] = 0;
             }
         }
     }
     return $permission_matrix;
 }
예제 #2
0
 /**
  * This will display add permission
  * @return $this|bool|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function addPermission()
 {
     access_check('manage_permissions');
     $permissions = Permissions::all();
     return view('users::admin.add-permission')->with('layout', $this->layout);
 }