<?php

namespace App\Actions\Sales;

use App\Models\Sale;
use Illuminate\Support\Facades\DB;

class SyncAccountsAction 
{
    public function __invoke(Sale $sale, array $accounts): void
    {
        DB::transaction(function () use ($sale, $accounts) {
            $sale->accounts()->sync($accounts);
        }, attempts: 2);
    }
}
