app/Http/Controllers/UserController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(UserRequest $request, $id)
    {
        try {
            $user = User::findOrFail($id);
            $user->roles()->sync($request->idRol);
            return redirect('usuarios')->with('success', 'Usuario actualizado');
        } catch (Exception | QueryException $e) {
            return back()->withErrors(['exception' => $e->getMessage()]);
        }
    }
public function update ( UserRequest $ request , $ id ) { try { $ user = User :: findOrFail ( $ id ) ; $ user -> roles ( ) -> sync ( $ request -> idRol ) ; return redirect ( 'usuarios' ) -> with ( 'success' , 'Usuario actualizado' ) ; } catch ( Exception | QueryException $ e ) { return back ( ) -> withErrors ( [ 'exception' => $ e -> getMessage ( ) ] ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .