This package is used to bind searchable keywords on model. Which you can directly use in your query.
Publish model & trait by executing below command.
php artisan vendor:publish --provider="RrKhatri\Keywordable\KeywordServiceProvider"
Migrate keywords table
php artisan migrate
Keywordable
trait should be added on model.- Sync keywords on model.
$model->syncKeywords("laravel", "coder"); // ["laravel", "coder"] -> both will work.
- Search models having matching keywords.
$query->havingKeywords("lara", "co"); // orHavingKeywords -> to apply filter as OR.
- Find models having exact keywords.
$query->havingExactKeywords("laravel", "coder"); // orHavingExactKeywords -> to apply filter as OR.
- Remove keywords from model.
$model->removeKeywords(); // will remove all keywords.
$model->removeKeywords("laravel"); // will remove specified keyword(s).
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.