grao-laravel-crud
v1.0.49
Published
Generator Migrations, Controler, Model, View, Routes for Laravel via CLI
Downloads
63
Maintainers
Readme
Grão CLI (Crud for Laravel)
A CLI for creating basic files for Laravel
- Creation of migrations.
- Creation of controllers.
- Creation of models.
- Creation of views.
- All in few commands =).
Usage (Install global)
$ npm i -g grao-laravel-crud
New Features!
- Standard version of Laravel Crud
- composer dumpautoload after the generate.
Usage (CLI) 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:
$ grao g table_name namespace
or
$ grao generate table_name namespace
| params | description |
| ------ | ------ |
| table_name
| The name of the database table |
| namespace
| The name of the Workspace / Namespace in Laravel |
Folder grao-config (CLI)
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 crud`s 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:
$ grao reset
or
$ grao r
routes.php
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.
Usage (CLI) Migrations
- 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
anddatabase/migrations/update
The file inside
database/migrations/create
will create the tables in the database to be used in the rollback and creation. The update file insidedatabase/migrations/update
will only serve to modify the database table.--update
To generate these files use the command below:
$ grao migrate table_name --fields="field1:string, field2:string, field3:text, field4:int, field1:bigInteger"
obs:
The file already comes with the autoincrement id
.
| 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:
$ grao migrate table_name --run
We can update a migration. The update file is in
database/migrations/update/table_name
:
$ grao migrate table_name --update
We can also run specific rollback with the command below:
$ grao migrate table_name --rollback
If you want you can run all created migrations.
$ grao migrate --run
We can rollback all migrations.
$ 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: [email protected]
License
MIT - see LICENSE