<?php

namespace App\Models\Rental;

use App\Models\Car;
use App\Models\Branch;
use App\Traits\BranchScoped;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class MaintenanceRecord extends Model
{
    use BranchScoped;

    protected $fillable = [
        'branch_id',
        'car_id',
        'description',
        'cost',
        'maintenance_date',
        'next_due_km',
        'next_due_date',
    ];

    protected $casts = [
        'cost' => 'decimal:2',
        'maintenance_date' => 'datetime',
        'next_due_date' => 'datetime',
    ];

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

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