<?php

namespace Modules\Booking\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\Booking\Database\Factories\BookingVehicleOptionFactory;
use Modules\Shared\Enums\VehicleOption;

/**
 * One Vehicle Option line on a Booking (e.g. "back_seat x2"). A booking can
 * have more than one of these — see domain.md §2.
 */
class BookingVehicleOption extends Model
{
    /** @use HasFactory<BookingVehicleOptionFactory> */
    use HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'booking_id',
        'vehicle_option',
        'passenger_count',
        'unit_price',
        'line_total',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'vehicle_option' => VehicleOption::class,
            'passenger_count' => 'integer',
            'unit_price' => 'decimal:2',
            'line_total' => 'decimal:2',
        ];
    }

    public function booking(): BelongsTo
    {
        return $this->belongsTo(Booking::class);
    }
}
