<?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;

    public const BODY_TYPES = [
        'sedan' => 'Sedan', 'hatchback' => 'Hatchback', 'suv' => 'SUV',
        'crossover' => 'Crossover', 'pickup' => 'Pickup', 'van' => 'Van',
        'truck' => 'Camion', 'coupe' => 'Coupé', 'wagon' => 'Break',
        'convertible' => 'Cabrio', 'minivan' => 'Minivan', 'moto' => 'Motocicletă',
    ];

    public const TRANSMISSION_TYPES = [
        'manual' => 'Manuală',
        'automatic' => 'Automată',
        'cvt' => 'CVT',
        'dsg' => 'DSG',
        'dct' => 'DCT (Dual-Clutch)',
        'amt' => 'AMT (Robot)',
    ];

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

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

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