5b68f4fa38
- Booking model with booking_vehicle_options line items (supports mixing vehicle options like front_seat + back_seat in one booking), price snapshot, status machine, and driver/car assignment fields - BookingService: front-seat max, disabled-option toggles, duplicate-option and whole-vehicle-exclusivity guards - CreateBookingAction, CancelBookingAction, AssignDriverAction - BookingRefGenerator: sequential EVB-AAAAA1-style refs via row lock - POST/GET/cancel booking API endpoints (Sanctum, ownership + admin policy) - BookingPlugin + Filament BookingResource: list, detail view, Cancel and Assign Driver actions (shared between table and detail page) - domain.md updated for multi-vehicle-option bookings (§2) and driver/ vehicle assignment (§5a)
28 lines
717 B
PHP
28 lines
717 B
PHP
<?php
|
|
|
|
namespace Modules\Booking\Exceptions;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Modules\Booking\Models\Booking;
|
|
use RuntimeException;
|
|
|
|
class DriverAssignmentNotAllowedException extends RuntimeException
|
|
{
|
|
public static function notConfirmed(Booking $booking): self
|
|
{
|
|
return new self(
|
|
"Booking [{$booking->booking_ref}] cannot have a driver assigned because its status is [{$booking->status->value}], not confirmed."
|
|
);
|
|
}
|
|
|
|
public function render(Request $request): ?JsonResponse
|
|
{
|
|
if ($request->expectsJson()) {
|
|
return response()->json(['message' => $this->getMessage()], 422);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|