osamaalmamri / laravel-search
这是我创建的包 laravel-search
1.0
2023-09-07 08:55 UTC
Requires
- php: ^8.0
- illuminate/database: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
- spatie/laravel-package-tools: ^1.9
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^6.23|^7.0
This package is auto-updated.
Last update: 2024-09-07 11:15:08 UTC
README
此包简化了具有复杂关系的模型搜索
安装
您可以通过 composer 安装此包
composer require osamaalmamri/laravel-search
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="laravel-search-config"
这是发布配置文件的内容
return [ // this is the key namein Request $request 'key' => "search" ];
使用方法
在模型中使用 searchable 类
use OsamaAlmamri\LaravelSearch\Searchable; class YourModal extends Model { use Searchable; // define the name of cols //if you need search in another fields of another table using the relation name then col name // you can search any related relation as the following public $searchable = ['name','description','user.name','user.phone','user.role.name']; }
致谢
许可协议
MIT 许可协议 (MIT)。请参阅 许可文件 了解更多信息。