コード例 #1
0
 /**
  * Method for updating an existing role with the given id in the database.
  *
  * @param $id
  * @param UpdateRoleRequest $request
  * @return mixed
  */
 public function update($id, UpdateRoleRequest $request)
 {
     $role = Role::find($id);
     $role->update($request->all());
     if (is_null($request->get('permissions'))) {
         $role->permissions()->sync([]);
     } else {
         $role->permissions()->sync($request->get('permissions'));
     }
     return redirect(route('rbac.roles.index'))->withSuccess('You have successfully updated a role.');
 }
コード例 #2
0
ファイル: RolesController.php プロジェクト: lufias/L5admin
 public function update(\App\Http\Requests\UpdateRoleRequest $request, $role_id)
 {
     // update the record
     $role = $this->role->update($role_id, $request->get('name'));
     // if actions is given, sync up the new one
     if ($request->get('actions')) {
         // get all permission ids
         $permissions = $this->getPermissionIds($this->permission->getPermissionByResourceAndAction($request->get('actions')));
         // sync this permission ids with the role
         $role->permissions()->sync($permissions);
     } else {
         $role->permissions()->sync([]);
     }
     // flash successfull message
     $request->session()->flash('success', 'Successfully update role.');
     // return back to previous
     return back();
 }
コード例 #3
0
ファイル: RoleController.php プロジェクト: exfriend/larabox
 /**
  * Update the specified Role in storage.
  *
  * @param  int $id
  * @param UpdateRoleRequest $request
  *
  * @return Response
  */
 public function update($id, UpdateRoleRequest $request)
 {
     $this->authorize('system.manage');
     $role = $this->roleRepository->findWithoutFail($id);
     if (empty($role)) {
         Flash::error('Role not found');
         return redirect(route('roles.index'));
     }
     $role = $this->roleRepository->update($request->all(), $id);
     $role->abilities()->sync($request->get('abilities'));
     Flash::success('Role updated successfully.');
     return redirect(route('roles.index'));
 }