42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class CitaRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$citaId = $this->route('cita')?->id;
|
|
|
|
return [
|
|
'mensaje_id' => ['nullable', 'exists:mensajes,id'],
|
|
'nombre_cliente' => ['required', 'string', 'max:255'],
|
|
'email_cliente' => ['required', 'email', 'max:255'],
|
|
'telefono_cliente' => ['required', 'string', 'max:50'],
|
|
'servicio' => ['required', 'string', 'max:255'],
|
|
'fecha' => ['required', 'date', 'after_or_equal:today'],
|
|
'hora_inicio' => ['required', 'date_format:H:i'],
|
|
'hora_fin' => ['nullable', 'date_format:H:i'],
|
|
'duracion' => ['required', 'integer', 'min:15', 'max:480'],
|
|
'estado' => ['required', Rule::in(['pendiente', 'confirmada', 'completada', 'cancelada'])],
|
|
'notas' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'fecha.after_or_equal' => 'La fecha debe ser hoy o posterior.',
|
|
'estado.in' => 'El estado debe ser: pendiente, confirmada, completada o cancelada.',
|
|
];
|
|
}
|
|
}
|