<?php

declare(strict_types=1);

namespace App\Models;

use App\Business\DataImport\Enums\DataImportRowStatus;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class DberpDataImportBatchRow extends Model
{
    protected $table = 'dberp_data_import_batch_rows';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'batch_id',
        'row_number',
        'status',
        'raw_snapshot',
        'error_messages',
        'created_record_type',
        'created_record_id',
        'external_key',
    ];

    protected function casts(): array
    {
        return [
            'batch_id' => 'integer',
            'row_number' => 'integer',
            'status' => DataImportRowStatus::class,
            'raw_snapshot' => 'array',
            'error_messages' => 'array',
            'created_record_id' => 'integer',
        ];
    }

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