Laravel Scout is a full-text search solution for Eloquent models. It provides a simple, driver-based approach to adding search functionality to your Laravel application, supporting drivers like Algolia and Meilisearch.
Scout was introduced to make integrating full-text search into Laravel applications straightforward, leveraging external search engines for powerful indexing and querying.
Install Scout:
composer require laravel/scout
Configure a driver (e.g., Algolia) in .env
:
SCOUT_DRIVER=algolia
ALGOLIA_APP_ID=your-app-id
ALGOLIA_SECRET=your-secret-key
Add the Searchable
trait to a model:
namespace App\Models;
use Laravel\Scout\Searchable;
class Post extends Model
{
use Searchable;
}
Search the model:
$posts = Post::search('Laravel')->get();
Laravel Scout streamlines full-text search, enabling powerful and scalable search capabilities for your application.