middleware( function ($request, $next) { $this->repository = app(AccountRepositoryInterface::class); $this->repository->setUser(auth()->user()); return $next($request); } ); } /** * @param MoveTransactionsRequest $request * * @return JsonResponse */ public function moveTransactions(MoveTransactionsRequest $request): JsonResponse { $accountIds = $request->getAll(); $original = $this->repository->findNull($accountIds['original_account']); $destination = $this->repository->findNull($accountIds['destination_account']); /** @var AccountDestroyService $service */ $service = app(AccountDestroyService::class); $service->moveTransactions($original, $destination); return response()->json([], 204); } }