jhacobs/laravel-searchable
Composer 安装命令:
composer require jhacobs/laravel-searchable
包简介
Search through models
README 文档
README
Search through models with laravel searchable
Installation
You can install the package via composer
composer require jhacobs/laravel-searchable
Usage/Examples
Prepare your models
Add the Searchable trait to the model you want to search through.
namespace App\Models\User; use Illuminate\Database\Eloquent\Model; use Jhacobs\Searchable\Searchable; class User extends Model { use Searchable; }
Then add the fields you want to be searchable to the $searchables property.
namespace App\Models\User; use Illuminate\Database\Eloquent\Model; use Jhacobs\Searchable\Searchable; class User extends Model { use Searchable; protected $searchables = [ 'name', 'email' ]; }
Searching models
You can search through your models by using the search scope.
User::search('Henk') ->get();
Running Tests
To run tests, run the following command
composer test
License
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-19