- Se agregó autorización basada en permisos en múltiples Requests. - Nuevos Requests para motivos de cancelación y tags con validación y autorización. - Se añadieron métodos de roles al modelo User (isDeveloper, isAdmin, isPrimary). - Se actualizó el acceso a Telescope usando validación por roles. - Mejora en el manejo de excepciones de autorización. - Actualización de RoleSeeder con nuevas convenciones de permisos. - Actualización de dependencias (composer.lock).
91 lines
4.0 KiB
PHP
91 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Repuve;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class VehicleUpdateRequest extends FormRequest
|
|
{
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return auth()->user()->can('vehicles.edit');
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'folio' => 'nullable|string|max:50|unique:records,folio,' . $this->route('id'),
|
|
// --- DATOS DEL VEHÍCULO ---
|
|
'vehicle.placa' => 'nullable|string|max:20',
|
|
'vehicle.marca' => 'nullable|string|max:100',
|
|
'vehicle.linea' => 'nullable|string|max:100',
|
|
'vehicle.sublinea' => 'nullable|string|max:100',
|
|
'vehicle.modelo' => 'nullable|string',
|
|
'vehicle.color' => 'nullable|string|max:50',
|
|
'vehicle.numero_motor' => 'nullable|string|max:50',
|
|
'vehicle.clase_veh' => 'nullable|string|max:50',
|
|
'vehicle.tipo_servicio' => 'nullable|string|max:50',
|
|
'vehicle.rfv' => 'nullable|string|max:50',
|
|
'vehicle.rfc' => 'nullable|string|max:13',
|
|
'vehicle.ofcexpedicion' => 'nullable|string|max:100',
|
|
'vehicle.fechaexpedicion' => 'nullable|date',
|
|
'vehicle.tipo_veh' => 'nullable|string|max:50',
|
|
'vehicle.numptas' => 'nullable|string',
|
|
'vehicle.observac' => 'nullable|string|max:500',
|
|
'vehicle.cve_vehi' => 'nullable|string|max:50',
|
|
'vehicle.nrpv' => 'nullable|string|max:50',
|
|
'vehicle.tipo_mov' => 'nullable|string|max:50',
|
|
|
|
// --- DATOS DEL TAG ---
|
|
'tag.tag_number' => 'nullable|string|max:32',
|
|
|
|
// --- DATOS DEL PROPIETARIO ---
|
|
'owner.name' => 'nullable|string|max:100',
|
|
'owner.paternal' => 'nullable|string|max:100',
|
|
'owner.maternal' => 'nullable|string|max:100',
|
|
'owner.rfc' => 'nullable|string|max:13',
|
|
'owner.curp' => 'nullable|string|max:18',
|
|
'owner.address' => 'nullable|string|max:255',
|
|
'owner.tipopers' => 'nullable|boolean',
|
|
'owner.pasaporte' => 'nullable|string|max:20',
|
|
'owner.licencia' => 'nullable|string|max:20',
|
|
'owner.ent_fed' => 'nullable|string|max:50',
|
|
'owner.munic' => 'nullable|string|max:100',
|
|
'owner.callep' => 'nullable|string|max:100',
|
|
'owner.num_ext' => 'nullable|string|max:10',
|
|
'owner.num_int' => 'nullable|string|max:10',
|
|
'owner.colonia' => 'nullable|string|max:100',
|
|
'owner.cp' => 'nullable|string|max:5',
|
|
'owner.telefono' => 'nullable|string|max:15',
|
|
|
|
// --- ARCHIVOS ---
|
|
'files' => 'nullable|array|min:1',
|
|
'files.*' => 'file|mimes:jpeg,png,jpg|max:2048',
|
|
'name_id' => 'nullable|array',
|
|
'name_id.*' => 'integer|exists:catalog_name_img,id',
|
|
'observations' => 'nullable|array',
|
|
'observations.*' => 'nullable|string|max:500',
|
|
'delete_files' => 'nullable|array',
|
|
'delete_files.*' => 'integer|exists:files,id',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'vehicle.modelo.string' => 'El modelo debe ser texto',
|
|
'vehicle.numptas.string' => 'El número de puertas debe ser texto',
|
|
'owner.tipopers.boolean' => 'El tipo de persona debe ser física o Moral',
|
|
'owner.cp.max' => 'El código postal debe tener máximo 5 caracteres',
|
|
'files.*.mimes' => 'Solo se permiten archivos JPG, PNG o JPEG',
|
|
'files.*.max' => 'El archivo no debe superar 2MB',
|
|
'observations.*.max' => 'La observación no debe superar 120 caracteres',
|
|
'delete_files.*.exists' => 'El archivo a eliminar no existe',
|
|
'folio.unique' => 'El folio ya existe en el sistema',
|
|
'folio.max' => 'El folio no puede exceder 50 caracteres',
|
|
'tag.tag_number.max' => 'El tag_number no puede exceder 32 caracteres',
|
|
];
|
|
}
|
|
}
|