<?php

namespace App\Commands\Balances;

use App\Commands\Command;
use App\Models\Balance;
use Illuminate\Support\Facades\DB;

class CreateBalanceCommand implements Command
{
    public function execute(array $data): mixed
    {
        return DB::transaction(
            callback: fn () => Balance::query()->updateOrCreate([
                'id' => $data['id'],
                'account_id' => $data['account_id'],
            ], $data),
            attempts: 2
        );
    }
}
