<?php

namespace App\Models;

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

class Vehicle extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'plate_number',
        'brand',
        'model',
        'year',
        'color',
        'vehicle_type',
        'image',
        'has_ac',
        'passenger_count',
        'is_4wd',
        'service_type',
        'driver_id',
        'is_available',
        'is_active',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'is_available' => 'boolean',
        'is_active' => 'boolean',
        'has_ac' => 'boolean',
        'is_4wd' => 'boolean',
    ];

    /**
     * Get the driver associated with this vehicle.
     */
    public function driver()
    {
        return $this->belongsTo(User::class, 'driver_id');
    }

    /**
     * Get the trips for this vehicle.
     */
    public function trips()
    {
        return $this->hasMany(Trip::class);
    }
}
