19peaches/laravel-generator

This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel CRUD Generator/Model/Migrate from just one command with including Controller, Service, Repository, Model, Migrations, routes.php update.

1.1.0 2017-02-01 03:56 UTC

This package is auto-updated.

Last update: 2022-01-07 09:40:56 UTC


README

The artisan command can generate the following items:

  • Migration File
  • Model
  • Repository
  • Service
  • Controller
  • View
    • index.blade.php
    • show.blade.php
    • create.blade.php
    • edit.blade.php
    • form.blade.php
  • adjusts routes.php
  • adjusts ModelFactory.php

Here is the full documentation.

Upgrade Guide.

Documentation is in process...

Documentation

  1. Installation
  2. Configuration
  3. Publish & Initialization
  4. Generator
  5. Supported Field Types
  6. Customize Templates
  7. Options
    1. Paginate Records
    2. Auth triat

Installation

  1. Add this package to your composer.json:

     "require": {
         "doctrine/dbal": "^2.5",
         "laracasts/flash": "dev-master",
         "laravelcollective/html": "^5.2"
     }
    
     "require-dev": {
         "19peaches/laravel-generator": "1.*"
     }
    
  2. Run composer update

     composer update
    
  3. Add the ServiceProviders to the providers array in config/app.php.
    As we are using these two packages laravelcollective/html & laracasts/flash as a dependency.
    so we need to add those ServiceProviders as well.

     Collective\Html\HtmlServiceProvider::class,
     Laracasts\Flash\FlashServiceProvider::class,
     Peaches\Generator\GeneratorServiceProvider::class,
    

    Also for convenience, add these facades in alias array in config/app.php.

     'Form'      => Collective\Html\FormFacade::class,
     'Html'      => Collective\Html\HtmlFacade::class,
     'Flash'     => Laracasts\Flash\Flash::class
    

Configuration

Publish Configuration file generator.php.

    php artisan vendor:publish

Config file (config/generator.php) contains path for all generated files

base_controller - Base Controller for all Controllers
base_name - Base directory path for base classes.

path_migration - Path where Migration file to be generated
path_model - Path where Model file to be generated
path_repository - Path where Repository file to be generated
path_service - Path where Service file to be generated
path_controller - Path where Controller file to be generated
path_views - Path where views will be created
path_request - Path where request file will be created
path_routes - Path of routes.php (if you are using any custom routes file)

namespace_model - Namespace of Model
namespace_repository - Namespace of Repository
namespace_service - Namespace of Service
namespace_controller - Namespace of Controller
namespace_request - Namespace for Request

model_extend_class - Extend class of Models

main_layout - Extend master layout

route_prefix - Prefix of scaffold route

use_repository_layer - Using repository layer

use_service_layer - Using service layer

Publish & Initialization

  1. Publish some common views like paginate.blade.php. php artisan generator:publish

  2. Publish template. php artisan generator:publish --templates

  3. Publish a base repository file php artisan generator:publish --baseRepository

Generator

Fire artisan command to generate Migration, Model, Scaffold with CRUD views from exist tables. This package can generate files from a specify table or from all tables in database.

This package require you to pass at least one argument for table name. If you want to pass many table name, a list table name will separate by comma.

Generate Migration From Exist Tables:

    php artisan generator:make:migrate TableName

Generate CRUD Scaffold:

    php artisan generator:make:scaffold TableName

Generate Model With Validation And Relationships:

    php artisan generator:make:model TableName

Generate Factory From Exist Tables:

    php artisan generator:make:factory TableName

Generate All Resource File:

    php artisan generator:make:resource TableName

e.g. php artisan generator:migrate php artisan generator:migrate posts,comments

php artisan generator:make:model 
php artisan generator:make:model posts,comments
php artisan generator:make:model --tables=posts,comments
php artisan generator:make:model --ignore=posts,comments
php artisan generator:make:model posts,comments --models=Post,Comment

php artisan generator:make:scaffold
php artisan generator:make:scaffold posts,comments
php artisan generator:make:scaffold --tables=posts,comments
php artisan generator:make:scaffold --ignore=posts,comments

php artisan generator:make:factory posts,comments

php artisan generator:make:resource posts,comments

Supported HTML Field Types

Here is the list of supported field types with options:

  • text
  • textarea
  • password
  • email
  • checkbox
  • number
  • date

Customize Templates

To use your own custom templates,

  1. Publish templates to /resources/generator-templates

     php artisan generator:publish --templates
    
  2. Leave only those templates that you want to change. Remove the templates that do not plan to change.

Options

Paginate Records

To paginate records, you can specify paginate option, e.g.

    php artisan generator:make:scaffold posts --paginate=10

Model use Auth

To use Auth trait, use auth option,

    php artisan generator:make:model users --auth

Credits

Original Laravel Generator is created by Bluecode.

Bugs are welcomed :)