<?php

namespace App\Modules\HR\Recruitment\Models;

use App\Models\User;
use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class RecruitmentOfferLetterStatusEvent extends Model
{
    use BelongsToTenant;

    public $timestamps = false;

    protected $table = 'recruitment_offer_letter_status_events';

    protected $fillable = [
        'tenant_id',
        'offer_letter_id',
        'from_status',
        'to_status',
        'action',
        'notes',
        'actor_user_id',
        'meta',
        'created_at',
    ];

    protected function casts(): array
    {
        return [
            'meta' => 'array',
            'created_at' => 'datetime',
        ];
    }

    public function offerLetter(): BelongsTo
    {
        return $this->belongsTo(RecruitmentOfferLetter::class, 'offer_letter_id');
    }

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