Posts Learn Components Snippets Categories Tags Tools About
/

Laravel Scout Manually Triggering Indexing Via Code

Learn how to trigger indexing for Laravel Scout via code the easy way.

Created on Sep 03, 2021

116 views

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();

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

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Sponsors 👑

+ Add Yours
)