<?php

namespace App\Models;

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

class ReconImportRow extends Model
{
    protected $fillable = [
        'batch_id',
        'row_number',
        'sale_date',
        'external_key',
        'external_label',
        'qty',
        'amount',
        'order_status',
        'excluded',
    ];

    protected $casts = [
        'sale_date' => 'date',
        'excluded'  => 'boolean',
    ];

    public function batch(): BelongsTo
    {
        return $this->belongsTo(ReconImportBatch::class, 'batch_id');
    }

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