<?php

namespace App\Models;

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

class ReconImportBatch extends Model
{
    protected $fillable = [
        'channel',
        'date_from',
        'date_to',
        'file_name',
        'row_count',
        'excluded_count',
        'status',
        'superseded_by',
        'template_snapshot',
        'imported_by',
    ];

    protected $casts = [
        'date_from'         => 'date',
        'date_to'           => 'date',
        'template_snapshot' => 'array',
    ];

    public function rows(): HasMany
    {
        return $this->hasMany(ReconImportRow::class, 'batch_id');
    }

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