public function getModels($filter = null)
 {
     $models = Role::sortable($this->index_view);
     if ($this->show_trash()) {
         $models = $models->withTrashed();
     }
     if (isset($filter)) {
         foreach ($this->filter_fields as $field) {
             if (trim($filter[$field]) != '') {
                 $values = explode(',', $filter[$field]);
                 $first = true;
                 foreach ($values as $value) {
                     if ($field == 'id') {
                         if ($first) {
                             $models = $models->Where($field, $value);
                             $first = false;
                         } else {
                             $models = $models->orWhere($field, $value);
                         }
                     } else {
                         $value = '%' . $value . '%';
                         if ($first) {
                             $models = $models->Where($field, 'LIKE', $value);
                             $first = false;
                         } else {
                             $models = $models->orWhere($field, 'LIKE', $value);
                         }
                     }
                 }
             }
         }
     }
     return $models;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $roleModel = new Role();
     $result = $roleModel->submitForDestroy($id);
     return response()->json(ViewAlert::getViewInstance()->create($result));
 }
 public function listRoles()
 {
     return Role::lists('role_title', 'id')->toArray();
 }
 public function hasRole($value)
 {
     $role = Role::select('id')->where('name', $value);
     if ($role) {
         return $this->roles->contains($role);
     }
     return false;
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $roles = Role::all()->lists('acronym', 'id');
     $model = $this->getModel($id);
     $model_roles = $model->roles->lists('id');
     return view($this->edit_view, compact(['model', 'roles', 'model_roles']));
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Role::find($id)->delete();
     Session::flash('flash_message', trans('admin/roles.form.delete_confirm'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $manageRow = Manage::find($id);
     return view('admin.rbac.manage.create')->with('manageRow', $manageRow)->with('roleRows', Role::all())->with('roleCheckeds', array_fetch($manageRow->roles->toArray(), 'id'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     try {
         $model = $this->getModel($id);
         $roles = Role::lists('name', 'id');
         $model_roles = $model->roles->lists('id');
         $departments = Department::lists('name', 'id');
         $model_departments = $model->departments->lists('id');
         $users = User::where('id', '<>', $id)->withTrashed()->lists('display_name', 'id');
         return view($this->edit_view, compact(['model', 'roles', 'model_roles', 'departments', 'model_departments', 'users']));
     } catch (Exception $e) {
         Flash::warning(trans($this->resource_name . 'not_found', ['model' => $this->model_name, 'id' => $id]));
         return $this->index();
     }
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = User::find($id);
     $action = 'admin.users.update';
     $countries = ['0' => trans('admin/users.form.country.placeholder')];
     $countries = array_merge($countries, Countries::all()->lists('name', 'id')->toArray());
     $roles = Role::all()->toArray();
     $role_user_array = $user->roles->toArray();
     $col_md = count($roles) >= 4 ? '3' : '4';
     //Number of columns depending of roles
     if ($role_user_array) {
         //Save only the user role id
         foreach ($role_user_array as $key => $value) {
             $role_user[] = $value['id'];
         }
     } else {
         $role_user = array();
     }
     return View('admin.users.edit', compact('user', 'action', 'countries', 'roles', 'role_user', 'col_md'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = User::find($id);
     $action = 'admin.users.update';
     $roles = Role::all()->toArray();
     $role_user_array = $user->roles->toArray();
     $col_md = count($roles) >= 4 ? '3' : '4';
     //Number of columns depending of roles
     if ($role_user_array) {
         //Save only the user role id
         foreach ($role_user_array as $key => $value) {
             $role_user[] = $value['id'];
         }
     } else {
         $role_user = array();
     }
     return View('admin.users.edit', compact('user', 'action', 'roles', 'role_user', 'col_md'));
 }