hepplerdotnet / fulltextsearch
Trait to implement FullTextSearch in Laravel Eloquent
2.0.3
2021-04-01 08:56 UTC
Requires
- php: >=8.0.0
- laravel/framework: >=8.0.0
This package is auto-updated.
Last update: 2024-10-29 05:54:06 UTC
README
PHP Trait to implement MySQL FullText Search in Eloquent Models
Installation & Usage
First, pull in the package through Composer.
Run composer require hepplerdotnet/fulltextsearch
And then include the Trait within your Eloquent Model to implement FullTextSearch .
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use HepplerDotNet\FullTextSearch\FullTextSearch; class FooBar extends Model { use FullTextSearch; /* Table Fields which should be searchable */ protected $searchable = [ 'title', 'description' ]; ... }
Create a fulltext index in MySQL for the fields.
Use it as scope on your Model
$result = FooBar::search('Foo')->get();