'Retrieved Contacts', 'message' => 'You have successfully retrieved a list of Contacts' ]; } /** @var CanListContacts */ private $canListContacts; /** @var ListsContacts */ private $listsContacts; /** * ListContactsControllerLogic constructor. * @param CanListContacts $canListContacts * @param ListsContacts $listsContacts */ public function __construct(CanListContacts $canListContacts, ListsContacts $listsContacts) { $this->canListContacts = $canListContacts; $this->listsContacts = $listsContacts; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $this->canListContacts->passes(); $query = $this->listsContacts->execute($this->listsContacts->deserializeFilters($request->input('filters'))); return $this->collectionResponse(ContactResource::collection($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }