thunder-birds-studio/laravel-helpers
Composer 安装命令:
composer require thunder-birds-studio/laravel-helpers
包简介
Helpers for laravel framework
README 文档
README
Helpers for laravel framework.
1. Helper fof(Class::class, $class_or_id) use for auto find the model using id or Model.
It may helper some reason. When use design pattern and you don't need it make a query every times when you pass data to your Services or Repositories.
Or when you not sure you should pass Model or only id to other class.
class FooController
{
/**
* @var FooService
*/
protected $foo_service;
/**
* @param FooService $foo_service
*/
public function __construct(FooService $foo_service)
{
$this->foo_service = $foo_service;
}
/**
* @param int $foo_id
*/
public function bar($foo_id)
{
$this->foo_service->bar($foo_id);
}
/**
* @param FooModel $foo
*/
public function barz(FooModel $foo)
{
$this->foo_service->bar($foo);
}
}
class FooService
{
/**
* @param FooModel|int $foo
*/
public function bar($foo)
{
$foo = fof(FooModel::class, $foo);
// Do somethings.
}
}
统计信息
- 总下载量: 67
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-04