<?php

namespace Modules\Routing\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Modules\Routing\Database\Factories\RoutePricingFactory;
use Modules\Shared\Enums\VehicleOption;

class RoutePricing extends Model
{
    /** @use HasFactory<RoutePricingFactory> */
    use HasFactory;

    protected $table = 'route_pricing';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'ev_route_id',
        'vehicle_option',
        'price',
        'is_blocked',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'vehicle_option' => VehicleOption::class,
            'price' => 'decimal:2',
            'is_blocked' => 'boolean',
        ];
    }

    public function route(): BelongsTo
    {
        return $this->belongsTo(EvRoute::class, 'ev_route_id');
    }
}
