定制 aammui/l9-repository 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aammui/l9-repository

最新稳定版本:v0.0.5

Composer 安装命令:

composer require aammui/l9-repository

包简介

Repository patterns for Laravel

README 文档

README

A basic data lever wrapper for Laravel's Eloquent model with the features such as Transformers, Filters, Caching etc.

Installation

composer require aammui/l9-repository

Uses

Transformers

First define a UserTransformer

class UserTransformer extends TransformerAbstract
{
    public function transform(User $user)
    {
        return [
            'id' => $user->id,
            'name' => $user->name
        ];
    }
}

and use it as,

app()->make(UserRepository::class)
    ->setTransformer(UserTransformer::class)
    ->get();

Or use with custom includes,

app()->make(UserRepository::class)
    ->setTransformer(UserTransformer::class, function(\League\Fractal\Manager $manager){
        $manager->parseIncludes('role');
    })
    ->get();

and add role to availableIncludes in UserTransformer

protected array $availableIncludes = [
    'role'
];

public function transform(User $user){...}

public function includeRole(User $user): Item
{
    $author = $user->role;

    return $this->item($author, new class extends TransformerAbstract {
        public function transform(Role $role): array
        {
            return [
                'id'    => $role->id,
                'label' => $role->label,
            ];
        }
    });
}

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 129
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固