abdallhsamy/helpers
Composer 安装命令:
composer require abdallhsamy/helpers
包简介
A Package contains some useful classes to help you develop faster
README 文档
README
A Package contains some useful classes to help you develop faster
benefits of using package
- you will be able to move migration files to sub directories ex:
database/migration/company/xxxxx_create_company_contacts_table.php - use pagination , filter and search without modifing controller methods or route params . ex :
/api/v1/users/search=Abdallah%20Samy&age=27&country_id=27&limit=15which :- @param
searchfor search , - @param
agefor filtering - @param
country_idfor filtering - and @param
limitfor pagination
- @param
Migration Directory Example
├── migrations │ ├── Employees │ │ ├── 2020_07_13_002708_create_xxxxx_table.php │ ├── General │ │ ├── 2020_06_25_094724_create_xxxxxx_table.php │ │ ├── 2020_06_25_154805_create_xxxxxx_table.php │ ├── Library │ │ ├── 2020_07_12_131550_create_xxxxxx_table.php │ │ ├── 2020_07_13_160900_create_xxxxxx_table.php │ │ ├── 2020_07_13_160903_create_xxxxxx_table.php │ │ └── 2020_07_13_160904_create_xxxxxx_table.php │ └── Users │ ├── 2020_06_14_145802_create_xxxxxx_table.php │ ├── 2020_06_14_145803_create_xxxxxx_table.php │ ├── 2020_06_15_110700_create_xxxxxx_table.php │ └── 2020_08_30_132633_create_xxxxxx_table.php └── seeds
Installation
using Composer
composer require abdallhsamy/helpers
Config File and Migrations
Publish package config file and migrations with the following command:
php artisan vendor:publish --provider="AbbdallhSamy\Helpers\Providers\HelperServiceProvider"
Then run migrations:
php artisan migrate
Traits and Contracts
Model
Add AbdallhSamy\Helpers\Traits\Models\{ActivityLogTrait, ModelFilters, ModelSearch} traits to your model.
See the following model example:
<?php namespace App\Models; use Illuminate\Foundation\Auth\User as Authenticatable; use AbdallhSamy\Helpers\Traits\Models\{ActivityLogTrait, ModelFilters, ModelSearch}; class User extends Authenticatable { use ActivityLogTrait, ModelFilters, ModelSearch; protected $filterItems = []; protected $searchItems = []; ...
Controller
<?php namespace App\Http\Controllers\API\V1; use App\Models\User; use App\Http\Controllers\Controller; use App\Http\Requests\User\UserCollection; use AbdallhSamy\Helpers\{Contracts\EnhancedQueryInterface, Traits\Controllers\EnhancedQuery}; class UserAPIController extends Controller implements EnhancedQueryInterface { use EnhancedQuery; private $model; public function __construct() { $this->model = User::latest(); } /** * must be implemented */ public function collection($users) { return new UserCollection($users); } /** * Display a listing of the resource. * @param Request $request * mixed * @return ResourceCollection */ public function index(Request $request) { return $this->query($request->all()); } ...
new Eloquent Builder Method toRawSql() Added
usage example :
return Recipe::select('dish_id', 'id') ->with('dish:name,id,price,photo') ->withCount('recipeMaterials') ->toRawSql();
output :
select `dish_id`, `id`, (select count(*) from `recipe_materials` where `recipes`.`id` = `recipe_materials`.`recipe_id`) as `recipe_materials_count` from `recipes`
abdallhsamy/helpers 适用场景与选型建议
abdallhsamy/helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 9, 最近一次更新时间为 2020 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 abdallhsamy/helpers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abdallhsamy/helpers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-06