<?php

namespace App\Models;

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

final class ReportJob extends Model
{
    protected $table = 'report_jobs';

    protected $fillable = [
        'job_no',
        'admin_user_id',
        'report_type',
        'export_format',
        'filter_json',
        'status',
        'output_path',
        'error_message',
        'finished_at',
    ];

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

    /** @return BelongsTo<AdminUser, ReportJob> */
    public function adminUser(): BelongsTo
    {
        return $this->belongsTo(AdminUser::class, 'admin_user_id');
    }
}
