ditscheri/eloquent-search
Composer 安装命令:
composer require ditscheri/eloquent-search
包简介
This is my package EloquentSearch
README 文档
README
PACKAGE IN DEVELOPMENT, DO NOT USE YET
Eloquent Search
This package lets you perform fast and local searches on your Eloquent Models. You can search foreign columns of related models too.
The approach is based on a gist by Jonathan Reinink (https://gist.github.com/reinink/28bd174087e929ffa1f150e3fe8ffbfa).
Installation
You can install the package via composer:
composer require ditscheri/eloquent-search
Usage
class Podcast extends Model { use \Ditscheri\EloquentSearch\Searchable; /** * The attributes that are searchable. * * @var string[] */ protected array $searchable = [ 'title', // make sure to add proper indexes to each of these columns 'description', 'author.first_name', 'author.last_name', 'comments.message', 'series.title', 'series.tags.name', ]; public function author() { return $this->belongsTo(User::class); } public function comments() { return $this->hasMany(Comment::class); } public function series() { return $this->belongsTo(Series::class); } } class PodcastController { public function index(Request $request) { return Podcast::search($request->input('q', null))->paginate(); } }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 830
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-14