transactions->run(function () use ($vatRateId, $direction): bool { $vatRate = $this->vatRates->findById($vatRateId) ?? throw new VatRateNotFound($vatRateId); $neighbour = $this->vatRates->neighbour($vatRate, $direction); if ($neighbour === null) { return false; } $vatRate->swapOrderWith($neighbour); $this->vatRates->save($vatRate); $this->vatRates->save($neighbour); return true; }); } }