fields() public méthode

Get model fields for indexing.
public fields ( Model $model ) : array
$model Illuminate\Database\Eloquent\Model
Résultat array
 public function testFields()
 {
     $fields = $this->config->fields($this->productRepoMock);
     $this->assertEquals(['name', 'description'], $fields);
     $fields = $this->config->fields($this->dummyRepoMock);
     $this->assertEquals(['first_field', 'second_field'], $fields);
 }
 public function testFields()
 {
     $fields = $this->config->fields($this->productRepoMock);
     $this->assertEquals(['name' => ['boost' => 1], 'description' => ['boost' => 1]], $fields);
     $fields = $this->config->fields($this->dummyRepoMock);
     $this->assertEquals(['first_field' => ['boost' => 0.1], 'second_field' => ['boost' => 0.2]], $fields);
 }
 /**
  * Update document in index for model
  *
  * @param Model $model
  */
 public function update(Model $model)
 {
     // Remove any existing documents for model.
     $this->delete($model);
     // Create new document for model.
     $doc = new Document();
     list($name, $value) = $this->config->privateKeyPair($model);
     // Add private key.
     $doc->addField(Field::keyword($name, $value));
     // Add model's class UID.
     list($name, $value) = $this->config->classUidPair($model);
     // Add class uid for identification of model's class.
     $doc->addField(Field::Keyword($name, $value));
     $fields = $this->config->fields($model);
     // Add fields to document to be indexed (but not stored).
     foreach ($fields as $field) {
         $doc->addField(Field::unStored(trim($field), strip_tags(trim($model->{trim($field)}))));
     }
     $optionalAttributes = $this->config->optionalAttributes($model);
     // Add optional attributes to document to be indexed (but not stored).
     foreach ($optionalAttributes as $fieldName => $fieldValue) {
         $doc->addField(Field::unStored(trim($fieldName), strip_tags(trim($fieldValue))));
     }
     // Add document to index.
     $this->index()->addDocument($doc);
 }
 /**
  * Update document in index for model
  *
  * @param Model $model
  */
 public function update(Model $model)
 {
     // Remove any existing documents for model.
     $this->delete($model);
     // Create new document for model.
     $doc = new Document();
     list($name, $value) = $this->config->primaryKeyPair($model);
     // Add private key.
     $doc->addField(Field::keyword($name, $value));
     // Add model's class UID.
     list($name, $value) = $this->config->classUidPair($model);
     // Add class uid for identification of model's class.
     $doc->addField(Field::Keyword($name, $value));
     // Get base fields.
     $fields = $this->config->fields($model);
     // Add fields to document to be indexed (but not stored).
     foreach ($fields as $fieldName => $options) {
         $fieldValue = $model->{trim($fieldName)};
         $field = Field::unStored(trim($fieldName), strip_tags(trim($fieldValue)));
         $field->boost = array_get($options, 'boost');
         $doc->addField($field);
     }
     // Get dynamic fields.
     $optionalAttributes = $this->config->optionalAttributes($model);
     // Add optional attributes to document to be indexed (but not stored).
     foreach ($optionalAttributes as $fieldName => $options) {
         $fieldValue = array_get($options, "value");
         $field = Field::unStored(trim($fieldName), strip_tags(trim($fieldValue)));
         $field->boost = array_get($options, "boost");
         $doc->addField($field);
     }
     // Set boost for model.
     $doc->boost = $this->config->boost($model);
     // Add document to index.
     $this->index()->addDocument($doc);
 }