|
|
@ -50,7 +50,7 @@ class PrestamoController extends Controller |
|
|
|
{ |
|
|
|
// Validación de datos |
|
|
|
$request->validate([ |
|
|
|
'nombre_solicitante' => 'required|string|max:255', |
|
|
|
'nombre_solicitante' => 'required|string|max:255|unique:prestamos,nombre_solicitante', |
|
|
|
'destino' => 'required|string|max:255', |
|
|
|
'fecha_hora_salida' => 'required|date', |
|
|
|
'fecha_hora_llegada' => 'required|date', |
|
|
@ -58,6 +58,7 @@ class PrestamoController extends Controller |
|
|
|
'domicilio' => 'required|string|max:255', |
|
|
|
'numero_personas' => 'required|integer', |
|
|
|
]); |
|
|
|
|
|
|
|
// Crea un nuevo préstamo |
|
|
|
$prestamo = new Prestamo(); |
|
|
|
$prestamo->nombre_solicitante = $request->nombre_solicitante; |
|
|
@ -73,6 +74,7 @@ class PrestamoController extends Controller |
|
|
|
|
|
|
|
return redirect()->route('prestamos.index')->with('success', 'Préstamo creado exitosamente.'); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Show the form for editing the specified resource. |
|
|
|
*/ |
|
|
@ -86,7 +88,7 @@ class PrestamoController extends Controller |
|
|
|
* Update the specified resource in storage. |
|
|
|
*/ |
|
|
|
public function update(Request $request, $id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Validación de datos |
|
|
|
$request->validate([ |
|
|
|
'nombre_solicitante' => 'required|string|max:255', |
|
|
@ -111,7 +113,7 @@ class PrestamoController extends Controller |
|
|
|
$prestamo->save(); // Guarda los cambios |
|
|
|
|
|
|
|
return redirect()->route('prestamos.index')->with('success', 'Préstamo actualizado correctamente.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Remove the specified resource from storage. |
|
|
|