New-Thanasoft/thanasoft-back/app/Http/Requests/UpdateVehicleRequest.php
kevin 284d228dc5 feat(vehicle): add vehicle+convoy feature with API, models, repos, UI
Adds model, repo, controller, and request classes for Vehicle and Convoy.
Registers routes for vehicles and convoys, updates client store.
Adds front‑end files to list, add, edit vehicles.
Cleans up console logging from client store.
2026-04-15 17:27:40 +03:00

36 lines
1.4 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UpdateVehicleRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$vehicleId = $this->route('vehicle') ?? $this->route('id');
return [
'photo_file_name' => ['nullable', 'string', 'max:255'],
'photo_file_url' => ['nullable', 'string', 'max:2048'],
'photo_mime_type' => ['nullable', 'string', 'max:100'],
'photo_size' => ['nullable', 'integer', 'min:0'],
'brand' => ['sometimes', 'required', 'string', 'max:255'],
'model' => ['sometimes', 'required', 'string', 'max:255'],
'registration_number' => ['sometimes', 'required', 'string', 'max:255', Rule::unique('vehicles', 'registration_number')->ignore($vehicleId)],
'vehicle_type' => ['nullable', Rule::in(['hearse', 'transport_vehicle', 'utility', 'sedan'])],
'fuel_type' => ['nullable', Rule::in(['diesel', 'petrol', 'electric', 'hybrid'])],
'year' => ['nullable', 'integer', 'min:1900', 'max:2100'],
'primary_user_id' => ['nullable', 'exists:employees,id'],
'status' => ['nullable', Rule::in(['active', 'maintenance', 'out_of_service'])],
'notes' => ['nullable', 'string'],
];
}
}