mkamel / searchable
v0.4.0
2022-12-02 18:44 UTC
Requires
- illuminate/support: ^9.0
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-08-30 01:28:53 UTC
README
1- 将此行添加到 app.php 文件中的 providers 数组中
MKamel\Searchable\SearchableServiceProvider::class,
2- 在您的模型中使用 Searchable 特性。
3- 这将使 Search 函数对您的模型可用
User::search([ 'name' => 'alex', 'older_than' => 20 ]);
4- 创建您的过滤器
class ByOlderThanFilter { public function apply($query, $key, $value) { return $query ->where('age', '>=', $value) } }
5- 您可以通过更改配置文件中的 filters_namespace 来更新过滤器目录。