/** * @param DocumentInterface $document the document where the indexable data must be applied to. * Override this method in a record to define which data should get indexed. By default all * record attributes get indexed. */ public function populateElasticDocument(DocumentInterface $document) { $document->setId($this->owner->getPrimaryKey()); foreach ($this->owner->attributeNames() as $name) { $document->{$name} = $this->owner->{$name}; } }