<?php

namespace App\Models;

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

class AccurateExportBatch extends Model
{
    protected $fillable = [
        'type',
        'date_from',
        'date_to',
        'file_name',
        'record_count',
        'exported_by',
    ];

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

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

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