<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Vehicule extends Model
{
    use HasFactory;
    protected $fillable = [
        'name',
        'luggage',
        'number_of_seats',
        'air_conditioning',
        'price_economy',
        'price_business'
    ];

    public function images()
    {
        return $this->hasMany(VehiculeImage::class);
    }

    public function getImageUrlsAttribute()
    {
        return $this->images->map(function($image) {
            return $image->image_url; // Utilise l'accesseur de SiteImage
        });
    }
}
