Example #1
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     // Don't allow changing the name of the administrator account.
     if (!$this->role->isAdministrator()) {
         $this->role->name = $this->request->input('name', $this->role->name);
     }
     $this->role->label = $this->request->input('label', $this->role->label);
     return $this->role->save();
 }
Example #2
0
 public function postEdit(RoleRequest $request)
 {
     $data = $request->all();
     $response = ['errors' => []];
     if ($data['id']) {
         $response['data'] = $this->repository->update($data);
     }
     return $response;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id, ModelRequest $request)
 {
     try {
         $model = $this->getModel($id);
         try {
             DB::beginTransaction();
             $model->update($request->all());
             DB::commit();
             flash()->info("{$this->model_name} saved");
             return redirect(route($this->show_route, [$model->id]));
         } catch (Exception $e) {
             DB::rollBack();
             throw $e;
         }
     } catch (Exception $e) {
         $errors = [];
         flash()->error($e->getMessage());
         return $request->response($errors);
     }
 }
 /**
  * 处理新增角色
  *
  * @auther yangyifan <*****@*****.**>
  */
 public function postAdd(RoleRequest $request)
 {
     $affected_number = AdminRoleModel::create($request->all());
     return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], true, url('admin/role/index')) : $this->response(400, trans('response.add_error'), [], false);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\Admin\RoleRequest $request, Role $role)
 {
     $role->update($request->all());
     return redirect('/admin/role')->with('flash_success', 'Роль успешно обновлена.');
 }
Example #6
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $this->role->name = $this->request->input('name');
     $this->role->label = $this->request->input('label');
     return $this->role->save();
 }