Пример #1
0
 public function getSort($sortBy = 'email', $orderBy = 'asc')
 {
     $inputs = array('sortBy' => $sortBy, 'orderBy' => $orderBy);
     $rules = array('sortBy' => 'required|regex:/^[a-zA-Z0-9 _-]*$/', 'orderBy' => 'required|regex:/^[a-zA-Z0-9 _-]*$/');
     $validation = \Validator::make($inputs, $rules);
     if ($validation->fails()) {
         return redirect('admin/users')->withErrors($validation);
     }
     if ($orderBy != 'asc' && $orderBy != 'desc') {
         $orderBy = 'asc';
     }
     if ($sortBy == 'group') {
         $users = User::LeftJoin('users_groups', 'users_groups.user_id', '=', 'users.id')->LeftJoin('groups', 'groups.id', '=', 'users_groups.group_id')->select('users.*', 'groups.name')->orderBy('groups.name', $orderBy)->paginate(20);
     } else {
         $users = User::orderBy($sortBy, $orderBy)->paginate(20);
     }
     $data = array('sortBy' => $sortBy, 'orderBy' => $orderBy, 'users' => $users);
     return view('redminportal::users/view', $data);
 }
Пример #2
0
 public function getIndex()
 {
     $models = User::orderBy($this->sortBy, $this->orderBy)->paginate($this->perpage);
     $data = array_merge($this->data, ['models' => $models]);
     return view('redminportal::users/view', $data);
 }