<?php

namespace App\Models;

use Database\Factories\ApplicationStatusHistoryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;

/**
 * @property int $id
 * @property int $adoption_application_id
 * @property string|null $from_status
 * @property string $to_status
 * @property string|null $notes
 * @property int|null $changed_by
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property-read AdoptionApplication $adoptionApplication
 * @property-read User|null $changedBy
 *
 * @method static \Database\Factories\ApplicationStatusHistoryFactory factory($count = null, $state = [])
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory query()
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereAdoptionApplicationId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereChangedBy($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereFromStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereNotes($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereToStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder<static>|ApplicationStatusHistory whereUpdatedAt($value)
 *
 * @mixin \Eloquent
 */
class ApplicationStatusHistory extends Model
{
    /** @use HasFactory<ApplicationStatusHistoryFactory> */
    use HasFactory;

    protected $fillable = [
        'adoption_application_id',
        'from_status',
        'to_status',
        'notes',
        'changed_by',
    ];

    /**
     * @return BelongsTo<AdoptionApplication, $this>
     */
    public function adoptionApplication(): BelongsTo
    {
        return $this->belongsTo(AdoptionApplication::class);
    }

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