public function update(UpdateRoleRequest $request, $id) { $role = $this->model->findOrFail($id); if ($role->name !== $request->get('name')) { if ($this->model->where('name', $request->get('name'))->count() > 0) { return Redirect::back()->withInput()->withErrors(['name' => trans('LaravelAdmin::laravel-admin.slugAlreadyExisits')]); } } $role->fill($request->all()); $role->save(); flash()->success(trans('LaravelAdmin::laravel-admin.rolEditionSuccess')); return Redirect::to('backend/roles'); }
/** * @param UpdateRoleRequest $request * @param $id * @return \Illuminate\Http\RedirectResponse */ public function update(UpdateRoleRequest $request, $id) { try { DB::transaction(function () use($request, $id) { $this->repository->update($request->all(), $id); }); } catch (ValidatorException $e) { return redirect()->back()->withErrors($e->getMessageBag()); } SweetAlert::success(trans('LaravelAdmin::laravel-admin.rolEditionSuccess')); return redirect()->to(config('laravel-admin.routePrefix', 'backend') . '/roles'); }