vdauchy/laravel-model-injector
Composer 安装命令:
composer require vdauchy/laravel-model-injector
包简介
README 文档
README
Laravel Model Injector
This package is a simple trait to help on Model Injection.
The main goal is to replace class set in config as in laravel-permission:
// In: config/permission.php return [ 'models' => [ 'permission' => Permission::class, 'role' => Role::class, ], ... ]; // In: src/PermissionRegistrar.php public function __construct(CacheManager $cacheManager) { $this->permissionClass = config('permission.models.permission'); $this->roleClass = config('permission.models.role'); ... }
And instead do:
// In: src/PermissionRegistrar.php use HasModelInjection; public function __construct(CacheManager $cacheManager) { $this->permissionClass = $this->mClass(Permission::class); $this->roleClass = $this->mClass(Role::class); ... }
To use their own class, any developer can do:
$this->app->bind(Permission::class, MyCustomPermission::class);
Current API:
mQuery(string $model): Builder: Let you build a query against this Model.
mNew(string $model, array $attributes = []): Model: Let you create a new instance of this Model.
mClass(string $model): string: Return the class associated to the Model.
mTable(string $model): string: Return the table's name of the Model".
mColumns(string $model): Collection: Return a Collection of columns.
统计信息
- 总下载量: 65
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-28