ditscheri / eloquent-search
这是我的包 EloquentSearch
0.0.5
2024-01-24 13:27 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^8.37|^9.0|^10.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^5.10|^6.0|^7.0
- nunomaduro/larastan: ^1.0.3|^2.0.1
- orchestra/testbench: ^6.15|^7.0|^8.0
- pestphp/pest: ^1.21|^2.0
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-24 15:04:54 UTC
README
此包处于开发中,请勿使用
Eloquent Search
此包允许您对 Eloquent 模型执行快速本地搜索。您还可以搜索相关模型的外部列。
该方法基于 Jonathan Reinink 的 gist (https://gist.github.com/reinink/28bd174087e929ffa1f150e3fe8ffbfa)。
安装
您可以通过 composer 安装此包
composer require ditscheri/eloquent-search
用法
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(); } }
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全漏洞
请审查 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可证
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。