<?php

namespace App\Commands\Transmittal;

use App\Commands\Command;
use App\Models\Transmittal;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class StoreTransmittalCommand implements Command
{

    public function execute(array $data): Model
    {
        return DB::transaction(
            callback: fn () => Transmittal::query()->updateOrCreate(['id' => $data['id'] ?? null], $data),
            attempts: 2
        );
    }
}
