middleware( function ($request, $next) { $this->repository = app(ExchangeRateRepositoryInterface::class); $this->repository->setUserGroup($this->validateUserGroup($request)); return $next($request); } ); } public function destroy(DestroyRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse { $date = $request->getDate(); if (null === $date) { throw new ValidationException('Date is required'); } $rate = $this->repository->getSpecificRateOnDate($from, $to, $date); if (null === $rate) { throw new NotFoundHttpException(); } $this->repository->deleteRate($rate); return response()->json([], 204); } public function destroySingle(CurrencyExchangeRate $exchangeRate): JsonResponse { $this->repository->deleteRate($exchangeRate); return response()->json([], 204); } }