<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class VehicleMaintenance extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'tenant_id',
        'vehicle_id',
        'date',
        'category',
        'description',
        'amount',
        'mileage',
        'vendor',
        'memo',
    ];

    protected $casts = [
        'date' => 'date',
        'amount' => 'integer',
        'mileage' => 'integer',
    ];

    /**
     * 차량 관계
     */
    public function vehicle(): BelongsTo
    {
        return $this->belongsTo(CorporateVehicle::class, 'vehicle_id');
    }

    /**
     * 테넌트 관계
     */
    public function tenant(): BelongsTo
    {
        return $this->belongsTo(Tenant::class);
    }

    /**
     * 카테고리 목록
     */
    public static function getCategories(): array
    {
        return ['주유', '정비', '보험', '세차', '주차', '통행료', '검사', '기타'];
    }
}
