<?php

namespace App\Domain\Financial\Models;

use App\Domain\Facility\Models\Facility;
use App\Domain\Financial\Enums\PaymentMethod;
use App\Domain\Shared\Traits\BelongsToBranch;
use App\Domain\Shared\Traits\BelongsToAcademy;
use App\Domain\Shared\Traits\HasUuid;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class FacilityRentPayment extends Model
{
    use HasUuid, BelongsToAcademy, BelongsToBranch, SoftDeletes;

    protected $fillable = [
        'academy_id',
        'branch_id',
        'facility_id',
        'period',
        'amount',
        'payment_method',
        'cheque_number',
        'cheque_date',
        'bank_name',
        'recipient_name',
        'payment_date',
        'notes',
        'created_by',
    ];

    protected function casts(): array
    {
        return [
            'amount' => 'integer',
            'payment_method' => PaymentMethod::class,
            'cheque_date' => 'date',
            'payment_date' => 'date',
        ];
    }

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

    public function branch(): BelongsTo
    {
        return $this->belongsTo(\App\Domain\Identity\Models\Branch::class);
    }

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