<?php

declare(strict_types=1);

namespace App\Models;

use App\Enums\MembershipStatus;
use Database\Factories\MemberStatusHistoryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class MemberStatusHistory extends Model
{
    /** @use HasFactory<MemberStatusHistoryFactory> */
    use HasFactory;

    const UPDATED_AT = null;

    protected $fillable = [
        'member_id',
        'from_status',
        'to_status',
        'reason',
        'effective_date',
        'changed_by',
    ];

    protected function casts(): array
    {
        return [
            'from_status' => MembershipStatus::class,
            'to_status' => MembershipStatus::class,
            'effective_date' => 'date',
        ];
    }

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

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