Files
famous-ly4-ev/app-modules/booking/src/Http/Requests/StoreBookingRequest.php
T
Nyan Lin Paing 8d74ac74cd
PHP Tests / php-tests (push) Failing after 9m1s
fix dashboard and apis
2026-08-16 23:50:39 +07:00

48 lines
1.9 KiB
PHP

<?php
namespace Modules\Booking\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Modules\Shared\Enums\VehicleOption;
/**
* Shape validation only — business rules (front-seat limit, disabled vehicle
* options, pricing) stay in BookingService/PricingService, not here.
*/
class StoreBookingRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
/**
* @return array<string, array<int, mixed>>
*/
public function rules(): array
{
return [
'ev_route_id' => ['required', 'integer', 'exists:ev_routes,id'],
'departure_time_slot_id' => ['required', 'integer', 'exists:departure_time_slots,id'],
'travel_date' => ['required', 'date'],
// One or more Vehicle Option lines — e.g. front_seat + back_seat together
// (domain.md §2). Duplicate-option/whole-vehicle-exclusivity rules stay in
// BookingService, not here.
'selections' => ['required', 'array', 'min:1'],
'selections.*.vehicle_option' => ['required', Rule::enum(VehicleOption::class)],
'selections.*.passenger_count' => ['required', 'integer', 'min:1'],
'passenger_name' => ['required', 'string', 'max:255'],
'passenger_phone' => ['required', 'string', 'max:50'],
'pickup_address' => ['required', 'string', 'max:500'],
'pickup_lat' => ['nullable', 'numeric', 'between:-90,90'],
'pickup_lng' => ['nullable', 'numeric', 'between:-180,180'],
'dropoff_address' => ['required', 'string', 'max:500'],
'dropoff_lat' => ['nullable', 'numeric', 'between:-90,90'],
'dropoff_lng' => ['nullable', 'numeric', 'between:-180,180'],
'is_round_trip' => ['sometimes', 'boolean'],
'return_travel_date' => ['nullable', 'date', 'required_if:is_round_trip,true'],
];
}
}