advancelearn/search-elequent
Composer 安装命令:
composer require advancelearn/search-elequent
包简介
By installing this package, you can easily search in ElQuent Laravel, even between nested relations
README 文档
README
Introduction
By installing this package, you can easily search the values and columns of each model You can use this package in your Laravel projects
Installation
You can install the package with this command
composer require advancelearn/search-elequent
Now you can add the desired trait in any of the models that you want to be searchable
use Advancelearn\SearchElequent\Searchable; class Order extends Model { use Searchable; /** * Scope to perform a search operation. * * @param \Illuminate\Database\Query\Builder $query * @param string $searchText * @return \Illuminate\Database\Query\Builder */ public function scopeSearch($query, string $searchText) { $searchColumns = ['order_number']; $relationColumns = [ 'address.user' => ['email'] // Nested relationship with address and user ]; return $this->search($query, $searchText, $searchColumns, $relationColumns); } /** * Define the address relationship. * * @return \Illuminate\Database\Eloquent\Relations\Relation */ public function address() { // Define your address relationship logic here } }
And for example, you can call this scope in your controller and pass the searched value to it:
$searchText = $request->q; // 'DE1253005' // $searchText2 = "info@gmail.com"; return Order::search($searchText)->get();
Conclusion
The package you created to add search functionality to Eloquent models is a powerful tool in software development. Using this package, you will be able to perform complex searches in models as well as in tabular and relational relationships of models.
Among the main features of this package, the following can be mentioned:
Ease of use: By defining a simple scope in Eloquent models, this package provides the possibility of performing complex searches easily.
Support for relationships: You can also access tabular and relational relationships of models in your searches, which makes it possible to search for data related to a model.
Extensibility: This package allows you to add search features to all your Eloquent models, so you can create different searches based on your needs and match the unique features of your system.
Improved efficiency: With the ability to search the database based on specific conditions, you can quickly retrieve the data you need and improve the efficiency of your system.
By using this package, improve the ability to search and filter your data and make Laravel software development more simple and efficient.
advancelearn/search-elequent 适用场景与选型建议
advancelearn/search-elequent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「laravel」 「eloquent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 advancelearn/search-elequent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 advancelearn/search-elequent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 advancelearn/search-elequent 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package to retrieve data from Google Search Console
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
A Laravel Eloquent model trait for translatable resource
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Help to manage meta data on Laravel Eloquent model
Abstraction Layer to index and search entities
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-19