resource = $this->collectResource($resource); } /** * Transform the resource into a JSON array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { return $this->collection->map->toArray($request)->all(); } /** * Create an HTTP response that represents the object. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse */ public function toResponse($request) { return $this->resource instanceof AbstractPaginator ? (new PaginatedResourceResponse($this))->toResponse($request) : parent::toResponse($request); } }