<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use App\Models\Concerns\Auditable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class Vehicle extends Model
{
    use Auditable, BelongsToTenant, SoftDeletes;

    protected $fillable = [
        'company_id', 'client_id',
        'make', 'model', 'year', 'vin', 'plate',
        'engine', 'gearbox', 'fuel', 'vehicle_class', 'mileage', 'color', 'notes',
    ];

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

    public function getDisplayNameAttribute(): string
    {
        return trim("{$this->make} {$this->model} " . ($this->year ?: ''));
    }
}
