rrkhatri / laravel-keywordable
Add keywords on model and filter models using keywords.
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rrkhatri/laravel-keywordable
Requires
- php: ^7.2|^8.0
 - ext-json: *
 - illuminate/database: ^8.40
 - illuminate/support: ~5|~6|~7|~8
 
This package is auto-updated.
Last update: 2025-10-14 21:42:44 UTC
README
This package is used to bind searchable keywords on model. Which you can directly use in your query.
Setup:
Publish model & trait by executing below command.
php artisan vendor:publish --provider="RrKhatri\Keywordable\KeywordServiceProvider"
Migrate keywords table
php artisan migrate
Usage:
Keywordabletrait 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).
Licence
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.