You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 31, 2018. It is now read-only.
@@ -211,25 +217,25 @@ use Illuminate\Database\Eloquent\Model;
211
217
212
218
class Contact extends Model
213
219
{
214
-
use AlgoliaEloquentTrait;
220
+
use AlgoliaEloquentTrait;
215
221
216
-
public function autoIndex()
217
-
{
218
-
if (\App::environment() === 'test') {
219
-
return false;
220
-
}
222
+
public function autoIndex()
223
+
{
224
+
if (\App::environment() === 'test') {
225
+
return false;
226
+
}
221
227
222
-
return true;
223
-
}
228
+
return true;
229
+
}
224
230
225
-
public static autoDelete()
226
-
{
231
+
public static autoDelete()
232
+
{
227
233
if (\App::environment() === 'test') {
228
234
return false;
229
235
}
230
236
231
237
return true;
232
-
}
238
+
}
233
239
}
234
240
```
235
241
@@ -278,7 +284,7 @@ class Contact extends Model
278
284
{
279
285
use AlgoliaEloquentTrait;
280
286
281
-
public static $objectIdKey = 'new_key';
287
+
public static $objectIdKey = 'new_key';
282
288
}
283
289
```
284
290
@@ -291,17 +297,19 @@ use Illuminate\Database\Eloquent\Model;
291
297
292
298
class Contact extends Model
293
299
{
294
-
use AlgoliaEloquentTrait;
300
+
use AlgoliaEloquentTrait;
295
301
296
-
public function indexOnly($index_name)
297
-
{
298
-
return (bool) $condition;
299
-
}
302
+
public function indexOnly($index_name)
303
+
{
304
+
return (bool) $condition;
305
+
}
300
306
}
301
307
```
302
308
303
309
## Relationships
304
310
311
+
### Relationships
312
+
305
313
By default the Algolia package will fetch the **loaded** relationships.
306
314
307
315
If you want to index records that didn't yet load any relations you can do it by loading them in the ```getAlgoliaRecord``` that you can create in your model.
@@ -311,11 +319,11 @@ It will look like:
311
319
```php
312
320
public function getAlgoliaRecord()
313
321
{
314
-
/**
315
-
* Load the categories relation so that it's available
316
-
* in the laravel toArray method
317
-
*/
318
-
$this->categories;
322
+
/**
323
+
* Load the categories relation so that it's available
324
+
* in the laravel toArray method
325
+
*/
326
+
$this->categories;
319
327
320
328
return $this->toArray();
321
329
}
@@ -326,14 +334,14 @@ In the resulted object you will have categories converted to array by Laravel. I
326
334
```php
327
335
public function getAlgoliaRecord()
328
336
{
329
-
/**
330
-
* Load the categories relation so that it's available
0 commit comments