<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class RateImportLog extends Model
{
    use HasFactory;

    protected $fillable = [
        'source',
        'triggered_by_user_id',
        'mode',
        'status',
        'date_from',
        'date_to',
        'rooms_processed',
        'days_processed',
        'rows_written',
        'message',
        'details_json',
        'completed_at',
    ];

    protected function casts(): array
    {
        return [
            'date_from' => 'date',
            'date_to' => 'date',
            'rooms_processed' => 'integer',
            'days_processed' => 'integer',
            'rows_written' => 'integer',
            'details_json' => 'array',
            'completed_at' => 'datetime',
        ];
    }

    public function triggeredBy()
    {
        return $this->belongsTo(User::class, 'triggered_by_user_id');
    }
}
