serializer)) { $this->serializer = new JsonApiSerializer; } // Automatically set the paginator on the response object if the // data being provided implements a paginator. if (is_null($this->paginator) && $this->data instanceof LengthAwarePaginator) { $this->paginator = new IlluminatePaginatorAdapter($this->data); } // Automatically set the resource name if the response data is a model // and the resource name is available on the model. if (is_null($this->resourceName) && $this->data instanceof Model) { if (defined(get_class($this->data) . '::RESOURCE_NAME')) { $this->resourceName = constant(get_class($this->data) . '::RESOURCE_NAME'); } } if (is_null($this->resourceName) && $this->data instanceof LengthAwarePaginator) { $item = collect($this->data->items())->first(); if ($item instanceof Model) { if (defined(get_class($item) . '::RESOURCE_NAME')) { $this->resourceName = constant(get_class($item) . '::RESOURCE_NAME'); } } } return parent::createData(); } }