2016-11-23 20 views

回答

4

您可以在您的模型中使用getAlgoliaRecord() method,并从中返回包含您想要编制索引的属性的数组。

实施例:

use Illuminate\Database\Eloquent\Model; 

class Contact extends Model 
{ 
    use AlgoliaEloquentTrait; 

    public function getAlgoliaRecord() 
    { 
     return [ 
      'indexedAttribute' => $this->indexedAttribute, 
      'otherIindexedAttribute' => $this->otherIindexedAttribute, 
      'nextIndexedAttribute' => $this->nextIndexedAttribute, 
     ]; 
    } 
}