mkamel/searchable

Installs: 12 869

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/mkamel/searchable

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

This package is auto-updated.

Last update: 2025-11-29 02:43:46 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.