2017 © Pedro PelΓ‘ez
 

library laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

image

hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  • Tuesday, November 28, 2017
  • by hariadi
  • Repository
  • 2 Watchers
  • 2 Stars
  • 108 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 16 % Grown

The README.md

Laravel Boilerplate Generator Commands

Build Status, (*1)

Generate Model, attribute, relation, scope trait and repository for Laravel 5 Boilerplate via console command, (*2)

Install

composer require --dev hariadi/laravel-boilerplate-generator

Laravel 5.7+

Package already support auto discover and ready to use., (*3)

Laravel 5.4

Register service provider by adding to your config/app.php:, (*4)

Hariadi\Boilerplate\GeneratorCommandServiceProvider::class,

If you want this lib only for dev, you can add the following code to your app/Providers/AppServiceProvider.php file, within the register() method:, (*5)

public function register()
{
    if ($this->app->environment() !== 'production') {
        $this->app->register(\Hariadi\Boilerplate\GeneratorCommandServiceProvider::class);
    }
    // ...
}

Show command list:, (*6)

php artisan list

You will see:, (*7)

    app
      app:attribute        Create a new attribute traits for model
      app:method           Create a new method traits for model
      app:model            Create a new Eloquent model class with attribute, relationship and scope traits
      app:relationship     Create a new relationship traits for model
      app:repository       Create a new repository class
      app:scope            Create a new scope traits for model

Usage

Generate Model

Options, (*8)

  • -N|--namespace : The namespace class. Output strategy will follow this namespace
php artisan app:model ModelName

Generate ModelName.php under Models directory, and traits for ModelNameAttribute, ModelNameRelationship, ModelNameScope under Models\ModelName\Traits directory., (*9)

Generate Attribute

Options, (*10)

  • -N|--namespace : The namespace class. Output strategy will follow this namespace
php artisan app:attribute ModelName

Generate ModelNameAttribute.php under Models/Traits/Attribute directory., (*11)

Generate Method

Options, (*12)

  • -N|--namespace : The namespace class. Output strategy will follow this namespace
php artisan app:method ModelName

Generate ModelNameMethod.php under Models/Traits/Method directory., (*13)

Generate Relation

Options, (*14)

  • -N|--namespace : The namespace class. Output strategy will follow this namespace
php artisan app:relation ModelName

Generate ModelNameRelationship.php under Models/Traits/Relationship directory., (*15)

Generate Scope

Options, (*16)

  • -N|--namespace : The namespace class. Output strategy will follow this namespace
php artisan app:scope ModelName

Generate ModelNameScope.php under Models/Traits/Scope directory., (*17)

Generate Repository

Options, (*18)

  • -d|--disable-softdelete : Disable softdelete method (forceDelete and restore)
php artisan app:repository Backend/ModelName

Generate ModelNameRepository.php under app/Repositories/Event directory., (*19)

Output strategy

Without --namespace option

Example files and directories output:, (*20)

php artisan app:model ModelName
php artisan app:model AnotherModelName
app/Models
β”œβ”€β”€ AnotherModelName
β”‚Β Β  β”œβ”€β”€ AnotherModelName.php
β”‚Β Β  └── Traits
β”‚Β Β      β”œβ”€β”€ Attribute
β”‚Β Β      β”‚Β Β  └── AnotherModelNameAttribute.php
β”‚Β Β      β”œβ”€β”€ Method
β”‚Β Β      β”‚Β Β  └── AnotherModelNameMethod.php
β”‚Β Β      β”œβ”€β”€ Relationship
β”‚Β Β      β”‚Β Β  └── AnotherModelNameRelationship.php
β”‚Β Β      └── Scope
β”‚Β Β          └──AnotherModelNameScope.php
└── ModelName
 Β Β  β”œβ”€β”€ ModelName.php
 Β Β  └── Traits
 Β Β      β”œβ”€β”€ Attribute
 Β Β      β”‚Β Β  └── ModelNameAttribute.php
 Β Β      β”œβ”€β”€ Method
 Β Β      β”‚Β Β  └── ModelNameMethod.php
 Β Β      β”œβ”€β”€ Relationship
 Β Β      β”‚Β Β  └── ModelNameRelationship.php
 Β Β      └── Scope
 Β Β          └── ModelNameScope.php

With --namespace option

Generated combined in given namspace option. Example files and directories output:, (*21)

php artisan app:model ModelName --namespace=Survey
php artisan app:model AnotherModelName --namespace=Survey
app/Models
└── Survey
 Β Β  β”œβ”€β”€ ModelName.php
 Β Β  β”œβ”€β”€ AnotherModelName.php
 Β Β  └── Traits
        β”œβ”€β”€ Attribute
        β”‚Β Β  β”œβ”€β”€ ModelNameAttribute.php
        β”‚Β Β  └── AnotherModelNameAttribute.php
        β”œβ”€β”€ Method
        β”‚Β Β  β”œβ”€β”€ ModelNameMethod.php
        β”‚Β Β  └── AnotherModelNameMethod.php
        β”œβ”€β”€ Relationship
        β”‚Β Β  β”œβ”€β”€ ModelNameRelationship.php
        β”‚Β Β  └── AnotherModelNameRelationship.php
 Β Β      └── Scope
            β”œβ”€β”€ ModelNameScope.php
            └── AnotherModelNameScope.php

License

The Laravel Boilerplate Generator command is open-sourced software licensed under the MIT license, (*22)

The Versions

28/11 2017

dev-master

9999999-dev https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

28/11 2017

v0.2.0

0.2.0.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

28/11 2017

v0.1.8

0.1.8.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

23/11 2017

v0.1.7

0.1.7.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

22/11 2017

v0.1.6

0.1.6.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

20/09 2017

v0.1.5

0.1.5.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

08/08 2017

v0.1.4

0.1.4.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

05/06 2017

v0.1.3

0.1.3.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

05/06 2017

v0.1.2

0.1.2.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

03/06 2017

v0.1.1

0.1.1.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope

01/06 2017

v0.1.0

0.1.0.0 https://github.com/hariadi/laravel-boilerplate-generator

Generate Model, attribute, relation, scope trait and repository for Laravel Boilerplate

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repository boilerplate command console model artisan traits attribute relation scope