Generator Migrations, Controler, Model, View, Routes for Laravel via CLI
npm install grao-laravel-crudA CLI for creating basic files for Laravel
- Creation of migrations.
- Creation of controllers.
- Creation of models.
- Creation of views.
- All in few commands =).
----------------------------------------------------
``sh
$ npm i -g grao-laravel-crud
`
----------------------------------------------------
----------------------------------------------------
- Standard version of Laravel Crud
- composer dumpautoload after the generate.
----------------------------------------------------
----------------------------------------------------
> This command generates the Controllers, Model and Views files. When reusing the same table_name it overwrites the previous file. We use the template files created in the project in the grao-config folder.
> Files in the config folder.
| files | description |
| ------ | ------ |
| controller.js.ejs | Model for modifiable Controller generation for laravel |model.js.ejs
| | Model for modifiable Models generation for laravel |routes.js.ejs
| | Model for modifiable Routes generation for laravel |index.js.ejs
| | Template for generating list page modifiable for laravel |edit.js.ejs
| | Template for form generation modifiable for laravel |show.js.ejs
| | Template for data visualization |
> Before running the command, the table in the database should exist.
> IMPORTANT: This module only uses MYSQL connection, reading the .env file.
> You can use the CLI migrations generator.
> COMMAND:
`sh
$ grao g table_name namespace
`
or
`sh
$ grao generate table_name namespace
`
| params | description |
| ------ | ------ |
| table_name | The name of the database table |namespace
| | The name of the Workspace / Namespace in Laravel |
----------------------------------------------------
----------------------------------------------------
> If you want to change something in the next 'crud',
> the grao-config folder will be created in your directory with .ejs files for modifications,
> any modification to these files will affect the generation of the cruds files in the application.
> If you want to re-create the folder just delete it and the files will come in the default.
> Or you can use the command below in laravel project.
> He had erased and recreated the folder:
``sh
$ grao reset
`
or
`sh
$ grao r
`
----------------------------------------------------
----------------------------------------------------
> Path: grao-config/routes.php
> This file adds the routes generated by the commands, always at the end of the file.
> Copy and paste into your Laravel route file.
----------------------------------------------------
----------------------------------------------------
- ATTENTION: This feature supports only Mysql database
> The migration system generates two files, one for creation and one for updating.
> These files are generated in database/migrations/create and database/migrations/update
> The file inside database/migrations/create will create the tables in the database to be used in the rollback and creation.database/migrations/update
> The update file inside will only serve to modify the database table. --update
> To generate these files use the command below:
`sh
$ grao migrate table_name --fields="field1:string, field2:string, field3:text, field4:int, field1:bigInteger"
`The file already comes with the autoincrement id
> obs: .
| params | description |
| ------ | ------ |
| table_name | The name of the database table |--fields
| | Name the fields with their types separated by a colon. |
> Go to the file make the necessary modifications and then execute the commands below to create the table in the database:
`sh
$ grao migrate table_name --run
`
> We can update a migration. The update file is in database/migrations/update/table_name:
`sh
$ grao migrate table_name --update
`
> We can also run specific rollback with the command below:
`sh
$ grao migrate table_name --rollback
`
> If you want you can run all created migrations.
`sh
$ grao migrate --run
`
> We can rollback all migrations.
`sh
$ grao migrate --rollback
`
| params | description |
| ------ | ------ |
| table_name | The name of the database table |run
| | Command to create |rollback
| | Command to return |update` | Command to update the table |
|
----------------------------------------------------
----------------------------------------------------
- Donations to always improve the project, thank you.
- PayPal: sueltonlima@gmail.com
----------------------------------------------------
MIT - see LICENSE