Skip to content

Commit 7d58954

Browse files
committed
Clarify conditional indexing for Scout
Conditional indexing only applies when using the save method on a model, the query builder or relationships directly. This is because the behavior on models and collections directly is meant to "force" them to be applied and ignores the `shouldBeSearchable` method.
1 parent f499cfe commit 7d58954

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scout.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ Sometimes you may need to only make a model searchable under certain conditions.
262262
return $this->isPublished();
263263
}
264264

265+
Note that this is only applied when manipulating models through the `save` method, queries or relationships. Directly making models and collections searchable would still override this behavior.
266+
267+
// Applied to...
268+
App\Order::where('price', '>', 100)->searchable();
269+
$user->orders()->searchable();
270+
$order->save();
271+
272+
// Not applied to...
273+
$orders->searchable();
274+
$order->searchable();
275+
265276
<a name="searching"></a>
266277
## Searching
267278

0 commit comments

Comments
 (0)