<?php

namespace App\Models;

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

class Dispute extends Model
{
    use HasFactory;

    protected $fillable = [
        'tenant_id',
        'dispute_number',
        'booking_id',
        'complaint_type',
        'reported_by_id',
        'reported_against_id',
        'description',
        'evidence_urls',
        'status',
        'resolution',
        'resolution_date',
        'compensation_amount',
    ];

    protected $casts = [
        'evidence_urls' => 'json',
        'resolution_date' => 'datetime',
        'compensation_amount' => 'decimal:2',
    ];

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

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

    public function reportedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'reported_by_id');
    }

    public function reportedAgainst(): BelongsTo
    {
        return $this->belongsTo(User::class, 'reported_against_id');
    }
}
