'Retrieved Document', 'message' => 'You have successfully retrieved a list of Document' ]; } /** @var CanListDocuments */ private $canListDocuments; /** @var ListsDocuments */ private $listsDocuments; /** * ListStandardSegmentLogic constructor. * @param CanListDocuments $canListDocuments * @param ListsDocuments $listsDocuments */ public function __construct(CanListDocuments $canListDocuments, ListsDocuments $listsDocuments) { $this->canListDocuments = $canListDocuments; $this->listsDocuments = $listsDocuments; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $document_type = $request->input('document_type'); $reference = $request->input('reference'); $status = $request->input('status'); $data = []; if ($document_type) { $data['document_type'] = $document_type; } if ($reference) { $data['reference'] = $reference; } if ($status) { $data['status'] = $status; } $this->canListDocuments->passes(); $query = $this->listsDocuments->execute($data); return $this->collectionResponse(DocumentResource::collection($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }