'Retrieved Transactions With Details', 'message' => 'You have successfully retrieved a list of transactions' ]; } /** @var ListsTransactions */ private $listsTransactions; /** * ListTransactionsLogic constructor. * @param ListsTransactions $listsTransactions */ public function __construct(ListsTransactions $listsTransactions) { $this->listsTransactions = $listsTransactions; } public function logic(Request $request) : JsonResponse { $filesystemDriver = Storage::getDefaultDriver(); if($filesystemDriver === 's3'){ $filePathForS3 = 'logs/list_mappable_transaction_with_details.log'; $textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $request->input('filters') . PHP_EOL; $existingContent = Storage::disk('s3')->get($filePathForS3); $updatedContent = $existingContent . $textToAppend; Storage::disk('s3')->put($filePathForS3, $updatedContent); } else{ $filePath = storage_path('logs/list_mappable_transaction_with_details.log'); $textToAppend = Carbon::now()->format('[Y-m-d H:i:s]') . ' ' . $request->input('filters') . PHP_EOL; file_put_contents($filePath, $textToAppend, FILE_APPEND); } $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters'))); return $this->collectionResponse(MappableTransactionWithDetailsResource::collection($query)); } }