Skip to content

rrkhatri/laravel-keywordable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Keywordable

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:

  • 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).

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.

Buy us a tree

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages