<?php

namespace App\Models\Rental;

use App\Models\Car;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;

class InsuranceClaim extends Model
{
    protected $table = 'insurance_claims';
    
    protected $fillable = [
        'car_id', 'rental_id', 'claim_number', 'accident_date',
        'description', 'estimated_damage_cost', 'insurance_coverage_amount',
        'deductible_paid', 'claim_status', 'settlement_amount',
        'attachments', 'created_by'
    ];

    protected $casts = [
        'accident_date' => 'date',
        'attachments' => 'array',
        'estimated_damage_cost' => 'decimal:2',
        'insurance_coverage_amount' => 'decimal:2',
        'deductible_paid' => 'decimal:2',
        'settlement_amount' => 'decimal:2'
    ];

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

    public function rental()
    {
        return $this->belongsTo(Rental::class);
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }
}
