mkamel/searchable

v0.4.0 2022-12-02 18:44 UTC

This package is auto-updated.

Last update: 2025-05-29 01:22:52 UTC


README

1- Add this line to your app.php file in providers array:

MKamel\Searchable\SearchableServiceProvider::class,

2- Use Searchable Trait in your Model.

3- That will make Search function available for you model

User::search([
  'name' => 'alex',
  'older_than' => 20
]);

4- Create your Filters:

class ByOlderThanFilter
{
  public function apply($query, $key, $value)
  {
    return $query
      ->where('age', '>=', $value)
  }
}

5- You can update the filters directory by changing filters_namespace in config file.