middleware(function (Request $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 { $first = Carbon::create(1970, 1, 1); $this->repository->deleteRates($from, $to); event(new DestroyedCurrencyExchangeRate($from, $to, $this->validateUserGroup($request), $first)); return response()->json([], 204); } public function destroySingleByDate(Request $request, TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse { $exchangeRate = $this->repository->getSpecificRateOnDate($from, $to, $date); if ($exchangeRate instanceof CurrencyExchangeRate) { $this->repository->deleteRate($exchangeRate); } if (!$exchangeRate instanceof CurrencyExchangeRate) { throw new FireflyException('Bla'); } event(new DestroyedCurrencyExchangeRate($from, $to, $this->validateUserGroup($request), $date)); return response()->json([], 204); } public function destroySingleById(Request $request, CurrencyExchangeRate $exchangeRate): JsonResponse { $from = $exchangeRate->fromCurrency; $to = $exchangeRate->toCurrency; $this->repository->deleteRate($exchangeRate); event(new DestroyedCurrencyExchangeRate($from, $to, $this->validateUserGroup($request), $exchangeRate->date)); return response()->json([], 204); } }