Posts Learn Components Snippets Categories Tags 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

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

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

new

PostSrc Code Components

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

View Components

Other Code Snippets

More