chhw/commander 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

chhw/commander

最新稳定版本:2.1.0

Composer 安装命令:

composer require chhw/commander

包简介

This package gives you to automatically generate service/repository class, which is extended by Laravel original make commands.

README 文档

README

This package extends Laravel generating commands.

Installation

Install by composer

    $ composer require chhw/commander

If you are under Laravel 5.5, please add this code in config/app.php below.

    <?php
        'providers' => [
            CHHW\Commander\CommanderServiceProvider::class,
        ],
    ?>

Also support Lumen now!!

In bootstrap/app.php, you should:

  1. uncomment $app->withEloquent();
  2. add $app->register(CHHW\Commander\CommanderServiceProvider::class);

And add config/database.php just like Laravel.

Usage

Generate Service:

Create a new service class.

    $ php artisan make:service UserService

Generate Repository:

Create a new repository class.

    $ php artisan make:repository UserRepository

Or you can create a new repository class with --model=

    $ php artisan make:repository UserRepository --model=User

Supported methods

You can use these methods in service:

  1. all($columns = ['*'])
  2. find($id, $columns = ['*'])
  3. firstOrFail($columns = ['*'])
  4. get($columns = ['*'])
  5. create(array $attributes = [])
  6. with($relations)
  7. destroy($ids)
  8. paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
  9. simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

Example:

app/Services/UserService.php

protected $userRepository;

public function __construct(UserRepository $repository)
{
    $this->userRepository = $repository;
}

public function getAll()
{
    return $this->userRepository->all();
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-24