Looking to hire Laravel developers? Try LaraJobs

laravel-keywordable maintained by rrkhatri

Description
Add keywords on model and filter models using keywords.
Author
Last update
2022/11/14 15:59 (dev-master)
License
Downloads
21

Comments
comments powered by Disqus

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