/**
  *
  * @return mixed
  */
 public function userRoles()
 {
     $users = User::orderBy('last_name')->orderBy('first_name')->paginate(25);
     $allRoles = Role::all();
     $rolesStr = array();
     foreach ($allRoles as $role) {
         $list = explode(" ", $role->role_name);
         $rolesStr[$role->role] = $list[0];
     }
     $userTableHead = $rolesStr;
     $userTable = array();
     foreach ($users as $user) {
         $roles = $user->roles;
         foreach ($allRoles as $role) {
             $rolesStr[$role->role] = isset($roles->find($role->id)->id) ? 'checked' : '';
         }
         $userTable[] = array('id' => $user->id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'roles' => $rolesStr);
     }
     return $this->make('userRoles', array('userTable' => $userTable, 'userTableHead' => $userTableHead, 'pageLinks' => $users->links()));
 }
Exemple #2
0
 /**
  * Проверка прав пользователя для указаной роли
  *
  * @param  string $strRole
  *
  * @return bool
  */
 public function isCompetent($strRole)
 {
     $role = Role::whereRole($strRole)->first();
     $roleAdmin = Role::whereRole('admin')->first();
     $res = RoleUser::whereUserId($this->id)->whereIn('role_id', array($roleAdmin->id, $role->id))->count();
     return $res > 0;
 }
 public function notices()
 {
     $role = Role::whereRole('messageSubscriber')->first();
     return $this->make('sendingNotices', array('themes' => MessageThemes::all(array('id', 'name', 'comment')), 'users' => $role->users));
 }