In this tutorial we're going to create a Laravel command we can use to import queried models into Algolia search index by using Laravel scout. https://paulund.co.uk/algolia-custom-query-import-with-laravel#what-is-laravel-scoutLaravel scout is a simple package that allows you to quickly use a service like Algolia which will quickly allow you to add full test searching to your eloquent models.
namespace App; use Laravel\Scout\Searchable; use Illuminate\Database\Eloquent\Model; class Post extends Model { use Searchable; } https://paulund.co.uk/algolia-custom-query-import-with-laravel#how-to-import-all-modelsLaravel scout comes with handy command that helps you import a whole model into Algolia, if the model has the Searchable trait.
Because of this global scope we need to create our own command to query for only published posts and import them into Algolia.
And that's it we've now created a command that makes a database query and them imports the results into Algolia search index so we can only search for published posts.