This package is a MySQL driver for Laravel Scout.
You can install the package via composer:
composer config repositories.globalia/laravel-scout-mysql git https://github.com/globalia/laravel-scout-mysql.git
composer require "globalia/laravel-scout-mysql" "^1.0"
You must add the Scout service provider and the package service provider in your app.php config:
// config/app.php
'providers' => [
...
Laravel\Scout\ScoutServiceProvider::class,
Globalia\LaravelScoutMysql\ScoutMysqlServiceProvider::class,
],
php artisan migrate
After you've published the Laravel Scout package configuration:
// config/scout.php
// Set your driver to mysql
'driver' => env('SCOUT_DRIVER', 'mysql'),
Here is an example of how to use the engine:
$result = Todo::search($term)
->where('boost(name)', 5)
->where('boost(tags)', 2)
->where('checked', 1)
->where('published_at >=', \Carbon::now());
return null === $limit ? $result->get() : $result->paginate($limit);
Instead of using the "Laravel\Scout\Searchable" trait, use this "Globalia\LaravelScoutMysql\Models\Concerns\HasSearchIndex"
otherwise you can use Laravel Scout as described in the official documentation
Since the index table is a model, you can search in it directly. Each result will be hydrated to its corresponding model.
$result = SearchIndex::search($term);