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 { $this->repository->deleteRates($from, $to); return response()->json([], 204); } public function destroySingleById(CurrencyExchangeRate $exchangeRate): JsonResponse { $this->repository->deleteRate($exchangeRate); return response()->json([], 204); } public function destroySingleByDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse { $exchangeRate = $this->repository->getSpecificRateOnDate($from, $to, $date); if (null !== $exchangeRate) { $this->repository->deleteRate($exchangeRate); } return response()->json([], 204); } }