moova/optimus-genie
Composer 安装命令:
composer require moova/optimus-genie
包简介
moova.io fork for esbenp: optimus/genie package
README 文档
README
Introduction
A base repository class for Eloquent with convenience methods that cover most queries. Useful to abstract away your persistence layer from your business code.
Dedicated to Genie
Dedicated to the World's best (and only) Genie in a bottle. Congrats on the freedom my man.
Installation
For Laravel 6 and above
composer require moova/optimus-genie dev-master
Implementation
The examples will use a hypothetical Eloquent model named User.
<?php namespace App\Repositories; use App\Models\User; use Optimus\Genie\Repository; class UserRepository extends Repository { protected function getModel() { return new User; } }
Options
Genie is already integrated with Optimus\Bruno.
See Bruno documentation for more information.
The $options key given by all get-methods takes the following format:
| Parameter | Value type | Description |
|---|---|---|
| includes | array | Array of relationships to eager load |
| sort | array | Array of sorting rules, e.g. [['key' => 'username', 'direction' => 'ASC']] |
| filter_groups | array | See Bruno documentation |
| limit | int | Rows per page |
| page | int | The page to start from (use with limit) |
Note: If you use the controller of Bruno it will automatically parse the request's query string into the correct format.
API
The examples will use a hypothetical Eloquent model named User.
get (array $options = [])
Get all User rows
getById ($id, array $options = [])
Get one User by primary key
getRecent (array $options = [])
Get User rows ordered by created_at descending
getRecentWhere (string $column, mixed $value, array $options = [])
Get User rows where $column=$value, ordered by created_at descending
getWhere (string $column, mixed $value, array $options = [])
Get User rows where $column=$value
getWhereArray (array $clauses, array $options = [])
Get User rows by multiple where clauses ([$column1 => $value1, $column2 => $value2])
getWhereIn (string $column, array $values, array $options = [])
Get User rows where $column can be any of the values given by $values
getLatest (array $options = [])
Get the most recent User
getLatestWhere (string $column, mixed $value, array $options = [])
Get the most recent User where $column=$value
delete ($id)
Delete User rows by primary key
deleteWhere ($column, $value)
Delete User rows where $column=$value
deleteWhereArray (array $clauses)
Delete User rows by multiple where clauses ([$column1 => $value1, $column2 => $value2])
Standards
This package is compliant with PSR-1, PSR-2 and PSR-4. If you notice compliance oversights, please send a patch via pull request.
Testing
$ phpunit
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
moova/optimus-genie 适用场景与选型建议
moova/optimus-genie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.11k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 moova/optimus-genie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 moova/optimus-genie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.11k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-09