2017 © Pedro Peláez
 

library laracrud

image

digitaldream/laracrud

  • Sunday, July 29, 2018
  • by digitaldreams
  • Repository
  • 10 Watchers
  • 104 Stars
  • 659 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 4 Open issues
  • 30 Versions
  • 33 % Grown

The README.md

Laravel Code Generator

Do you have a well structed database and you want to make a Laravel Application on top of it. By using this tools you can generate Models which have necessary methods and property, Request class with rules, generate route from controllers method and its parameter and full features form with validation error message and more with a single line of command. So lets start. See demo code and slides, (*1)

Installation

composer require digitaldream/laracrud --dev

Setting

  1. Add this line to config/app.php providers array . Not needed if you are using laravel 5.5 or greater
    LaraCrud\LaraCrudServiceProvider::class
  1. Then Run
    php artisan vendor:publish --provider="LaraCrud\LaraCrudServiceProvider"

Commands

Then you can see new commands by running 'php artisan', (*2)

  • laracrud:model {tableName} {name?} {--on=} {--off=}: Create model based on table
  • laracrud:request {Model} {name?} {--resource=} {--controller=} {--api}: Create Request Class/es based on table
  • laracrud:Controller {Model} {name?} {--parent=} {--only=} {--api}: Create Controller Class based on Model
  • laracrud:mvc {table} {--api}: Run above commands into one place
  • laracrud:route {controller} {--api}: Create routes based on controller method
  • laracrud:view {Model} {--page=(index|create|edit|show|form|table|panel|modal)} {--type=} {--name=} {--controller=}
  • laracrud:migration {table}: Create a migration file based on Table structure. Its opposite of normal migration file creation in Laravel
  • laracrud:policy {model} {--controller=} {--name=}
  • laracrud:package {--name=}
  • laracrud:transformer {model} {name?}: Create a dingo api transformer for a model
  • laracrud:test {controller} {--api}: Create test methods for each of the method of a controller

N.B: --api option will generate api resource. Like Controller, Request, Route, Test. Dingo API compatible code will be generated . See API documentation, (*3)

How to Use

Create a Model

There are some good practice for model in Laravel. Use scope to define query, define fillable, dates, casts etc. Also define relation, setAttribute and getAttribute for doing work before and after model save and fetch., (*4)

We are going to create this thing automatically by reading table structure and its relation to others table., (*5)

    php artisan laracrud:model users

By default Model Name will be based on Table name. But Model name can be specified as second parameter. Like below, (*6)

php artisan laracrud:model users MyUser

Video Tutorial, (*7)

Create Request

A well structured table validate everything before inserting . You can not insert a illegal date in a birth_date column if its data type set to date.So if we have this logic set on table why we should write it on Request again. Lets use this table logic to create a request class in laravel., (*8)

php artisan laracrud:request MyUser

Here MyUser is Eloquent Model. From LaraCrud version 4.* this command accept Model Name instead of Table, (*9)

Like Model Name we can also specify a custom request name., (*10)

php artisan laracrud:request User RegisterRequest

Also If you like to create multiple request for your resourceful controller then, (*11)

php artisan laracrud:request User –-resource=index,show,create,update,destroy

It will create a folder users on app/Http/Requests folder and create these request classes. Sometimes you may like to create individual request class for each of your controller method then., (*12)

php artisan laracrud:request User –-controller=UserController
php artisan laracrud:request User --controller=UserController --api //this will generated Request for API usages

It will read your controller and create request classes for your Public method, (*13)

video tutorial, (*14)

Create Controller

    php artisan laracrud:controller User
    //Or Give a controller name.
    php artisan laracrud:controller User MyUserController
    //Or we can give a sub namespace
    php artisan laracrud:controller User User/UserController
    //It will create a folder User to controllers
    php artisan laracrud:controller Comment --parent=Post // it will create a sub resource CommentController

This will create a controller which have create, edit, save and delete method with codes . It also handle your relation syncronization, (*15)

video tutorial, (*16)

Create View

A typical form represent a database table. E.g. for a Registration form it has all the input field which is necessary for users table. Most of the time we use Bootstrap to generate a form . It has error field highlighting if validation fails. Also display value. This all can be done by, (*17)

 php artisan laracrud:view User --page=form
 php artisan laracrud:view User --page=index --type=panel //There are three type of layout for index page panel,table and tabpan
 php artisan laracrud:view User --controller=UserController // Create all the views which is not created yet for this controller

 ```
 Here **User** is Eloquent Model. From LaraCrud version 4.* this command accept Model Name instead of Table

This will create a complete users crud view. 

[video tutorial](https://www.youtube.com/watch?v=RjRFWABwXnA&list=PLcGdsjZbEjRtxROY7mlHcJQcSwxx9L8NB&index=5)

## Create Route

Routes are the most vital part of a laravel application.
WE create routes by its public methods and parameter. 
Lets do this work to rotue command.
```php 
    php artisan laracrud:route UserController
    php artisan laracrud:route UserController --api // generate api routes for this conroller

If you have some routes already redine for then do not worry. It will create routes for which does not define yet. Please use forward slash(/) for sub namespace. For example,, (*18)

 php artisan laracrud:route Auth/AuthController

Policy

Laravel have default policy generator. It works like same with one extra feature that is create policy method based on controller public methods., (*19)

php artisan laracrud:policy User 
// will create policy class with basic methods
php artisan laracrud:policy User --controller=UserController
// create method based on Controller public methods

Package

Packages gives us opportunity to create/use components into our existing application. That make our code reusable. Laravel package has similar structure as a Laravel application has., (*20)

php artisan laracrud:package Hello

This will create a folder same structure as a Laravel application has into your /packages folder See Package documentation Video tutorial, (*21)

Test

We need to test our routes endpoints. To create test class based on a controller do the following, (*22)

php artisan laracrud:test UserController
// or to make api test just pass --api like below
php artisan laracrud:test UserController --api

Transformer

Transformer are a vital part of Dingo API. To expose a model to api endpoint Transformer play media between api and model., (*23)

php artisan laracrud:transformer User

See API documentation, (*24)

Create everything at once

If we need all the command to then just to, (*25)

    php artisan laracrud:mvc users
    php artisan laracrud:mvc users --api // create all the API related resources

It will create Model, Request, Controller, View. Then you just need to run route command to create routes., (*26)

Migration

Somethings we may need to create a migration file from a table. Then this command will be useful. It will generate all the necessary code for your migration files. So your migration file is ready to use., (*27)

php artisan laracrud:migration users

Customize Code Template

Coding Style differ from developer to developer. So you can control how your code will be generated. Code templates are organized by folder in resources/vendor/laracrud/templates . Go there and change the style. After that your code will be generated by reading these files. Please do not remove or change @@placeHolder@@. This will be replaced by application., (*28)

NB: only for mysql database

It is recommended to take a look in the generated file before use it., (*29)

Like my work? If so hire me on upwork, (*30)

The Versions

29/07 2018

v1.x-dev

1.9999999.9999999.9999999-dev

  Sources   Download

27/07 2018

dev-master

9999999-dev https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

27/07 2018

3.1.4

3.1.4.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

12/07 2018

3.1.3

3.1.3.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

11/07 2018

3.1.2

3.1.2.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

04/02 2018

3.1.1

3.1.1.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

04/02 2018

3.1.0

3.1.0.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

31/01 2018

3.0.1

3.0.1.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

31/01 2018

3.0.0

3.0.0.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud code generator laravel code generator

16/12 2017

2.1.4

2.1.4.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

13/12 2017

2.1.3

2.1.3.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

12/12 2017

2.1.2

2.1.2.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

12/12 2017

2.1.1

2.1.1.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

18/11 2017

2.1.0

2.1.0.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

11/10 2017

2.0.1

2.0.1.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

11/10 2017

2.0

2.0.0.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

04/03 2017

1.1.3

1.1.3.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

01/03 2017

1.1.2

1.1.2.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

18/11 2016

1.1.1

1.1.1.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

05/10 2016

1.1.0

1.1.0.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

18/09 2016

1.0.9

1.0.9.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

17/09 2016

1.0.8

1.0.8.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

17/09 2016

1.0.7

1.0.7.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

11/09 2016

1.0.6

1.0.6.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

10/09 2016

1.0.5

1.0.5.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

09/09 2016

1.0.4

1.0.4.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

08/09 2016

1.0.3

1.0.3.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

07/09 2016

1.0.2

1.0.2.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

07/09 2016

1.0.1

1.0.1.0 https://github.com/digitaldreams/laracrud

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

 

laravel crud

06/09 2016

1.0.0

1.0.0.0 https://github.com/digitaldreams/data-converter

CRUD means CREATE, READ, UPDATE AND DELTE are common work in almost every web application. Laravel has also CRUD. We use Model, View, Controller, Request, Route's for CRUD. A well structured database are the blueprint of a web application. So We can create Model, View, Controller, Request from a database table

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

laravel crud