You see, I have a User table with a variable called role, for which I have this form:
@extends('layouts.app')
@section('content')
@Logged()
@include('partials.errors')
<form method="POST" action="../puesto">
{{ csrf_field() }}
<div class="form-group">
<label for="rol" class="col-md-12 control-label"> <h2>{{ __("rol elegido") }}</h2>
</label>
<input name="rol" type="radio" value="administrador"> Administrador<br>
<input checked="checked" name="rol" type="radio" value="cliente"> Cliente
</div>
<button type="submit" name="addrol" class="btn btn-default"> {{ __("Ingresar rol") }}
</button>
</form>
@else
<h1 class="text-center text-mute" style="color:#FF0000"> {{ __("¡DEJA DE HACER EL INDIO Y INICIA SESIÓN!") }} </h1>
@endLogged
@endsection
Once the form is done, we go to this code in web.php:
Route::post('/puesto','UserController@acto');
Which brings me to the following:
public function acto(Request $request){
$normas=[
'rol' => 'required',
];
$this->validate($request,$normas);
Auth::user()->rol=$request->rol;
Auth::user()->save();
return back()->with('message', ['success', __("Rol seleccionado correctamente.")]);
}
The return at the end will return me to the form, but I'm not interested in that, but I want you to take me to the main page ( Route :: get ('/', 'PlantsController @ index' );).
I have tried 2 back () but it gives an error. I have also tried putting 'return view (vegetal.index)' but it gives an error. How do I achieve it?