I have a small problem with one of my routes ...
I have my index which shows me several products (9 to be exact) when selecting one of my products therefore my route changes with the specification of my product example: "store \ donuts" in the donuts view I have a small form to get in touch with me to give reports of the products.
My problem arises when filling out my form and sending it to my BD my route changes to "store \ thank-contact" and I would like that depending on the product I choose the route show me the message of thanks along with the product that select example "store \ dona \ thank-contact" and as all my forms I have them linked to a single controller at the time of sending always send me to "store \ gracias-contacto" I do not know how to generate dynamic routes or if that is the best option or if there is an even simpler I leave part of my code
<form action="{{URL::to('save-contact-info')}}" method="POST" id="formulario">
{!! csrf_field() !!}
<div class="title-form">
<h3>
Informes
</h3>
</div>
<div class="info-form">
<div class="form-group">
<label>Nombre:</label>
<input type="text" name="nombre" class="form-control input-lg">
</div>
<div class="form-group">
<label>Email:</label>
<input type="text" name="email" class="form-control input-lg">
</div>
<div class="form-group">
<label>Teléfono:</label>
<input type="text" name="telefono" class="form-control input-lg">
</div>
<input type="hidden" name="producto" value="Donas">
<div class="form-group">
<button class="btn btn-lg btn-solicitar" type="submit">
Enviar
</button>
</div>
</div>
</form>
these are my routes
Route::get('donas', 'reposteriaController@donas');
Route::get('pasteles', 'resposteriaController@pasteles');
Route::post('save-contact-info', 'reposteriaController@saveContactInfo');
/*-- Lograr madar el modelo por la url--*/
Route::get('gracias-contacto', 'reposteriaController@gracias');
and these are my controllers
public function donas(){
return view('donas');
}
public function pasteles(){
return view('pasteles');
}
public function saveContactInfo(Request $request){
$nombre = $request->input('nombre');
$email = $request->input('email');
$telefono = $request->input('telefono');
$modelo = $request->input('modelo');
$nuevo_usuario = new ContactoReposteria;
$nuevo_usuario->nombre = $nombre;
$nuevo_usuario->email = $email;
$nuevo_usuario->telefono = $telefono;
$nuevo_usuario->modelo = $modelo;
$nuevo_usuario->save();
$datos = array(
'nombre' => $nombre,
'email' => $email,
'telefono' => $telefono,
'modelo' => $modelo
);
Mail::send('front.contacto-reposteria', $datos, function($message) use ($datos){
$message->to('[email protected]')
->subject('Contacto Reposteria');
});
return redirect('gracias-contacto');
}
public function gracias(){
return view('front.gracias');
}
}
As you can see I have two types of products here and I would like to be able to pass the model name through the route so that I can identify which product is selected and depending on the product it is displayed in my url "tienda {modelo- product} \ thanks-contact "
Thanks in advance for your help and your suggestions !!!!