Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Commit

Permalink
Merge pull request #174 from ItaloBC/patch-1
Browse files Browse the repository at this point in the history
Added Visibility concerns for indexing a Model
  • Loading branch information
julienbourdeau committed Mar 5, 2018
2 parents 328f1d4 + a1aa6d6 commit 97a2389
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,22 @@ public function getAlgoliaRecord()

# Indexing

## Visibility

By default, Algolia will only be able to access **visible** attributes of your model. So, for example, you will receive a `No content in PUT request` exception when using this example code, because `invisible_attribute` key returns an empty/null variable.

```php
protected $visible = ['visible_attribute', 'other_visible_attribute'];

public function getAlgoliaRecord()
{
return [
'invisible_attribute' => $this->invisible_attribute
];
}
```

Before Indexing, be sure to have correctly listed your visible attributes. To bypass this safety mask imposed by Laravel, you may use `$this->attributes['invisible_attribute']` to access directly to the attribute even if is not visible, but the recommendation is to avoid this type of access to attributes in your Model.

## Manual Indexing

Expand Down Expand Up @@ -480,7 +495,6 @@ To clear an index, use the `clearIndices` class method:
Contact::clearIndices();
```


# Manage indices


Expand Down

0 comments on commit 97a2389

Please sign in to comment.