Home / Snippets / Laravel Scout Manually Triggering Indexing Via Code
Laravel Scout Manually Triggering Indexing Via Code cover

Laravel Scout Manually Triggering Indexing Via Code

252

3 years ago

0 comments

To manually trigger the index of a model you can do it using code in your app or via the command line.

How to Trigger Indexing in Laravel Scout?


The way to trigger is to call the "searchable()" method at the end of the eloquent query and it will index all the records.
<?php

Post::all()->serachable();
To manually trigger a relationship then you can refer to the model instance as follows.
<?php

$post = Post:first();
$post->comments()->searchable();
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this