transactions->run(function () use ($jobId, $taskId, $itemId, $direction): bool { $item = $this->finder->find($jobId, $taskId, $itemId); $neighbour = $this->items->neighbour($item, $direction); if ($neighbour === null) { return false; } $item->swapOrderWith($neighbour); $this->items->save($item); $this->items->save($neighbour); return true; }); } }