Laravel Gii refers to sunshinev/laravel-gii, uses laravel7 + vue + elemnt-ui architecture, the api uses resftul api, the front and back ends are separated, the project code is released using php artisan vendor:publish, it does not rely on the extension itself, and is all deployed to each directory of the project. Below, can be flexibly modified according to needs
[TOC]
stub
template. Because it parses the MySQL table structure and generates templates based on fields, the currently generated Model class only supports MySQL. Please ensure that the three fields id
, created_at
, and updated_at
of the MySQL table structure must exist.
### Please install laravel7 first for the expansion package (other versions have not been tested)
Via Composer
$ composer require skyyouare/laravel-gii --dev
需要先按
1、composer require laravel/ui --dev
2、php artisan ui vue
3、npm install
4、npm install element-ui vue-router qs --save-dev
5、php artisan vendor:publish --tag gii.config --tag gii.views --tag gii.images --tag gii.js --tag gii.blade --tag gii.sass --tag gii.controller --tag gii.request --tag gii.route --tag gii.exception --tag gii.provider --force
6、运行 npm run watch-poll 编译
After the release is completed, the route has been registered. You can access the Gii page through the following route. Please make sure to configure the database (otherwise an error will be reported), website domain name (ip), etc.
http:[domain]/gii/model
Form description
The generated file list, blue represents new files, red represents existing files but are different, and white represents existing files.
For example, if the generated Model namespace is specified as AppModelsAdminAlarmLog
, then the generated directory structure is:
.app
├── Http
│ └── Requests
│ └── Admin
│ └── AlarmLogRequests.php
├── Models
│ └── Admin
│ ├── AlarmLogModel.php
│ └── AlarmLog.php
├── Observers
│ └── Models
│ └── Admin
└── └── AlarmLogObserver.php
Through the above structure, we can discover the relationship between namespaces and directories.
The creation of CRUD needs to rely on the previously created model.
This operation will also generate:
Form description
If the class of the specified namespace is AppHttpControllersAdmin
, the controller is AlarmLogController
, and the associated Model is AppModelsAdminAlarmLog
, then the generated directory structure is:
app
├── Http
│ └── Controllers
│ │ └── Admin
│ │ └── AlarmLogController.php
│ └── Requests
│ └── Admin
│ └── AlarmLogRequests.php
├── Models
│ └── Admin
│ ├── AlarmLogModel.php
│ └── AlarmLog.php
└── Observers
└── Models
└── Admin
└── AlarmLogObserver.php
and the generated view files
.resources
└── pages
└── admin
└── alarmlog
├── list.vue
├── edit.vue
├── create.vue
└── detail.vue
Note: Routes are appended. Do not generate CRUD multiple times. Routes will be automatically added to the routing file. According to the Controller's namespace AppHttpControllersAdminAlarmLogController
, the following routes will be generated, so please access the route directly.
//--------- append route 2020-08-27 09:58:16----------
{
name: 'alarmlog',
path:'/alarmlog/list',
component: resolve =>void(require(['./pages/alarmlog/list.vue'], resolve))
},
{
name: 'alarmlog',
path:'/alarmlog/create',
component: resolve =>void(require(['./pages/alarmlog/create.vue'], resolve))
},
{
name: 'alarmlog',
path:'/alarmlog/edit',
component: resolve =>void(require(['./pages/alarmlog/edit.vue'], resolve))
},
{
name: 'alarmlog',
path:'/alarmlog/detail',
component: resolve =>void(require(['./pages/alarmlog/detail.vue'], resolve))
},
Contains comprehensive addition, deletion, and modification functions
MIT. Please see the license file for more information.