hassamulhaq / laravel-model-relation-search
Laravel 包,用于通过模型和模型关系进行搜索。
0.0.1
2023-03-28 13:44 UTC
Requires
- php: ^8.1
- illuminate/database: ^10.4
- illuminate/support: ^10.4
This package is not auto-updated.
Last update: 2024-09-25 19:01:47 UTC
README
Laravel 包,用于通过模型和模型关系进行搜索。
安装
composer required hassamulhaq/laravel-model-relation-search
使用方法
- 在您的模型中使用
ModelRelationSearchableTrait
特性。 - 在您的模型中定义
$searchable_columns
属性来选择要搜索的列。
示例
use HassamUlHaq\LaravelModelRelationSearch\ModelRelationSearchableTrait; class Book extends Model { use ModelRelationSearchableTrait; protected $searchable_columns = [ 'title', 'author.bio', //'author.companies.name' ]; public function authors() { return $this->hasOne(Author::class); }