2017 © Pedro Peláez
 

library generators

This package extends the core file generators that are included with Laravel 5

image

yish/generators

This package extends the core file generators that are included with Laravel 5

  • Sunday, March 4, 2018
  • by Mombuyish
  • Repository
  • 4 Watchers
  • 42 Stars
  • 10,760 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 16 Versions
  • 19 % Grown

The README.md

Laravel Oh Generators

Build Status Total Downloads Latest Stable Version License License , (*1)

This package extends the core file generators that are included with Laravel 5 or later., (*2)

Requirement

PHP >= 7

Laravel >= 5

  • 5.4 before using branch 1.1.x
  • 5.5 ~ 5.7 using branch 2.0.x
  • 5.8 - 8.x using branch 3.x.x

Installation

Install via composer ``` bash $ composer require yish/generators, (*3)


#### Registing Service Provider If you are using laravel 5.5 or later, you can use auto discover, you don't need put in service provider to `app.php`. ``` php <?php //app.php 'providers' => [ \Yish\Generators\GeneratorsServiceProvider::class, ],

Generating Service

It can be generating class service. ``` bash $ php artisan make:service UserService, (*4)

``` php
<?php
namespace App\Services;

use Yish\Generators\Foundation\Service\Service;

class UserService
{
    protected $repository;

    //
}

Also, it supports abstract service. You should inject your repository or model and then use it. ``` php all() create($attributes) first() firstBy($column, $value) find($id) findBy($column, $value) get() getBy($column, $value) update($id, $attributes) updateBy($column, $value, $attributes) destroy($id) destroyBy($column, $value) paginate($page = 12) paginateBy($column, $value, $page = 12), (*5)


## Generating Repository It can be generating class repository. ``` bash $ php artisan make:repository UserRepository

``` php <?php namespace App\Repositories;, (*6)

use Yish\Generators\Foundation\Repository\Repository;, (*7)

class UserRepository { protected $model;, (*8)

//

}, (*9)

Also, it supports abstract repository.
You should inject your model and then use it.
``` php
all($columns = ['*'])
create($attributes)
update($id, array $attributes, array $options = [])
updateBy($column, $value, array $attributes = [], array $options = [])
first($columns = ['*'])
firstBy($column, $value, $columns = ['*'])
find($id, $columns = ['*'])
findBy($column, $value, $columns = ['*'])
get($columns = ['*'])
getBy($column, $value, $columns = ['*'])
destroy($ids)
destroyBy($column, $value)
paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
paginateBy($column, $value, $perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

Generating Transformer

It can be generating class transformer. ``` bash $ php artisan make:transformer UserTransformer, (*10)

### Support
#### TransformContract
``` php
<?php
namespace Yish\Generators\Foundation\Transform;
interface TransformContract
{
    public function transform($attributes);
}

Helper / transformer()

``` php // $instance => Transformer class. // $attributes => Need transform data, maybe array or collection etc. transformer(UserTransformer::class, $data);, (*11)


## Generating Formatter It can be generating class formatter. ``` bash $ php artisan make:formatter UserFormatter

``` php <?php, (*12)

namespace App\Formatters;, (*13)

use Illuminate\Http\Request; use Yish\Generators\Foundation\Format\FormatContract; use Yish\Generators\Foundation\Format\Statusable;, (*14)

class PostFormatter implements FormatContract { public function format(Request $request, $items = [], $message = '', $status = 200) { // } }, (*15)

### Support
#### FormatContract
``` php
<?php
namespace Yish\Generators\Foundation\Format;
use Illuminate\Http\Request;
interface FormatContract
{
    public function format(Request $request, $items = []);
}

Statusable

You can use Statusable trait to help you faster building formalize format. Set property $status = true, you can get success format. $status must be boolean, if not you will get exception. ``` php <?php, (*16)

namespace App\Formatters;, (*17)

use Illuminate\Http\Request; use Yish\Generators\Foundation\Format\FormatContract; use Yish\Generators\Foundation\Format\Statusable;, (*18)

class PostFormatter implements FormatContract { use Statusable;, (*19)

protected $status = true;

}, (*20)

If not, you can set `false` to get failed format.
``` php
<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;

class PostFormatter implements FormatContract
{
    use Statusable;

    protected $status = false;
}

If you need customize message, you can do: ``` php <?php, (*21)

namespace App\Formatters;, (*22)

use Illuminate\Http\Request; use Yish\Generators\Foundation\Format\FormatContract; use Yish\Generators\Foundation\Format\Statusable;, (*23)

class PostFormatter implements FormatContract { use Statusable;, (*24)

protected $status = false;

public function message()
{
    return 'hello world'.
}

}, (*25)

Or you can customize status code, you can do:
``` php
<?php

namespace App\Formatters;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Yish\Generators\Foundation\Format\FormatContract;
use Yish\Generators\Foundation\Format\Statusable;
use Yish\Generators\Foundation\Format\Formatter;

class Success extends Formatter implements FormatContract
{
   use Statusable;

    protected $status = false;

    public function code()
    {
        return Response::HTTP_ACCEPTED;
    }
}

If you need to customize what you need, check out Yish\Generators\Foundation\Format\Statusable get more detail., (*26)

Helper / formatter()

``` php // $request => Must instance of Illuminate\Http\Request. // $instance => Formatter class. // $items => data. formatter(request(), UserFormatter::class, $data);, (*27)


## Generating Presenter It can be generating class presenter. ``` bash $ php artisan make:presenter UserPresenter

``` php <?php, (*28)

namespace App\Presenters;, (*29)

class UserPresenter { // }, (*30)


## Generating Foundation It can be generating class foundation. ``` bash $ php artisan make:foundation Taggable

``` php <?php, (*31)

namespace App\Foundation;, (*32)

class Taggable { // }, (*33)


## Generating Transport It can be generating class transport. ``` bash $ php artisan make:transport UserTransport

``` php <?php, (*34)

namespace App\Transports;, (*35)

class UserTransport { // }, (*36)


## Generating Parser It can be generating class parser. ``` bash $ php artisan make:parser UserParser

``` php <?php, (*37)

namespace App\Parsers;, (*38)

use Yish\Generators\Foundation\Parser\Parser;, (*39)

class UserParser extends Parser { public function parse(array $items) { return parent::parse($items); }, (*40)

public function keys()
{
    return [
        'name',
        'ages',
        'location'
    ];
}

}, (*41)

``` php
$parser = app(UserParser::class)->parse(['Yish', 30, 'Taipei']);
// ['name' => 'Yish', 'ages' => 30, 'location' => 'Taipei'];

Generating Response

It can be generating class response., (*42)

``` bash $ php artisan make:response UserResponse, (*43)


``` php <?php namespace App\Responses; use Illuminate\Contracts\Support\Responsable; class UserResponse implements Responsable { public function toResponse($request) { // } }

The Versions

03/06 2017

1.1.1

1.1.1.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php >=5.6.4

 

The Development Requires

by Yish

laravel generator patterns

01/06 2017

1.1.0

1.1.0.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php >=5.6.4

 

The Development Requires

by Yish

laravel generator patterns

25/05 2017

1.0.9

1.0.9.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php >=5.6.4

 

The Development Requires

by Yish

laravel generator patterns

25/05 2017

1.0.8

1.0.8.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

by Yish

laravel generator patterns

25/05 2017

1.0.7

1.0.7.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

by Yish

laravel generator patterns

24/05 2017

1.0.6

1.0.6.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

by Yish

laravel generator patterns

24/05 2017

1.0.5

1.0.5.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

by Yish

laravel generator patterns

23/05 2017

1.0.4

1.0.4.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

  • php ^5.5.9 || ^7.0

 

The Development Requires

by Yish

laravel generator patterns

22/05 2017

1.0.3

1.0.3.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

 

by Yish

laravel generator patterns

18/05 2017

1.0.2

1.0.2.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

 

by Yish

laravel generator patterns

16/05 2017

1.0.1

1.0.1.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

 

by Yish

laravel generator patterns

16/05 2017

1.0.0

1.0.0.0 https://github.com/Mombuyish/Laravel-Oh-Generators

This package extends the core file generators that are included with Laravel 5

  Sources   Download

MIT

The Requires

 

by Yish

laravel generator patterns