<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class PassengerExtraService extends Model
{
    protected $fillable = [
        'title',
        'subtitle',
        'description',
        'image_path',
        'price_estimate',
        'sort_order',
        'is_active',
    ];

    protected $casts = [
        'price_estimate' => 'decimal:2',
        'sort_order' => 'integer',
        'is_active' => 'boolean',
    ];

    public function requests(): HasMany
    {
        return $this->hasMany(PassengerExtraServiceRequest::class, 'passenger_extra_service_id');
    }

    public function imagePublicUrl(): ?string
    {
        if (empty($this->image_path)) {
            return null;
        }

        return asset('storage/'.$this->image_path);
    }
}
