-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a1ec8d
commit 307ba74
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# MySQL FullText Search Trait | ||
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 | ||
|
||
<?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 | ||
|
||
```php | ||
$result = FooBar::search('Foo')->get(); | ||
``` | ||
|