public function update($id, UpdatePermissionRequest $request)
    {
        $permission = $this->permissionRepository->findWithoutFail($id);

        if (empty($permission)) {
            Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.permissions.index'));
        }

        $input = $request->all();

        $permission = $this->permissionRepository->update([
            'name' => $input['name'],
        ], $id);

        $roles = [];

        if (!empty($input['roles'])) {
            foreach ($input['roles'] as $role) {
                $roles[$role] = $role;
            }
        }

        $permission->roles()->sync($roles);

        Flash::success(trans('l5starter::messages.update.success'));

        return redirect(route('admin.permissions.index'));
    }
public function update($id, UpdatePermissionRequest $request)
    {
        $permission = $this->permissionRepository->findWithoutFail($id);

        if (empty($permission)) {
            Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.permissions.index'));
        }

        $input = $request->all();

        $permission = $this->permissionRepository->update([
            'name' => $input['name'],
        ], $id);

        $roles = [];

        if (!empty($input['roles'])) {
            foreach ($input['roles'] as $role) {
                $roles[$role] = $role;
            }
        }

        $permission->roles()->sync($roles);

        Flash::success(trans('l5starter::messages.update.success'));

        return redirect(route('admin.permissions.index'));
    }
public function update ( $ id , UpdatePermissionRequest $ request ) { $ permission = $ this -> permissionRepository -> findWithoutFail ( $ id ) ; if ( empty ( $ permission ) ) { Flash :: error ( trans ( 'l5starter::messages.404_not_found' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; } $ input = $ request -> all ( ) ; $ permission = $ this -> permissionRepository -> update ( [ 'name' => $ input [ 'name' ] , ] , $ id ) ; $ roles = [ ] ; if ( ! empty ( $ input [ 'roles' ] ) ) { foreach ( $ input [ 'roles' ] as $ role ) { $ roles [ $ role ] = $ role ; } } $ permission -> roles ( ) -> sync ( $ roles ) ; Flash :: success ( trans ( 'l5starter::messages.update.success' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; }
Update the specified Permission in storage.

@param  int $id
@param UpdatePermissionRequest $request

@return Response
Update the specified Permission in storage .