'Fetched Transaction', 'message' => 'You have successfully retrieved a Transaction' ]; } /** @var CanFetchTransaction */ private $canFetchTransaction; /** @var FetchesTransaction */ private $fetchesTransaction; /** * FetchTransactionLogic constructor. * @param CanFetchTransaction $canFetchTransaction * @param FetchesTransaction $fetchesTransaction */ public function __construct(CanFetchTransaction $canFetchTransaction, FetchesTransaction $fetchesTransaction) { $this->canFetchTransaction = $canFetchTransaction; $this->fetchesTransaction = $fetchesTransaction; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { $this->canFetchTransaction->passes(); $query = $this->fetchesTransaction->execute(['id' => $request->route('transaction_id')]); if($request->input('storages')){ $query->storages = $request->input('storages'); //from middleware } return $this->resourceResponse(new TransactionWithStorageResource($query)); } }