laravel5.4でscaffoldしたい : amranidev/scaffold-interface

# amranidev/scaffold-interface

- packagist
    - https://packagist.org/packages/amranidev/scaffold-interface

# scaffold simple table

マウスで作業する

1. http://127.0.0.1/ へアクセスしてユーザを作る（ログインしてないと作業途中でエラーする）
2. http://127.0.0.1/scaffold へアクセスしてカーソルでポチポチと作業する
3. コンソールで`php artisan migirate`する
4. http://127.0.0.1/scaffold へ再度アクセス（リフレッシュ）してからLink（青い丸）をクリック


二重線の範囲が設定済みのroute

```:console
$ php artisan route:list

+--------+-----------+-----------------------------------------------+--------------------+----------------------------------------------------------------------------+--------------+
| Domain | Method    | URI                                           | Name               | Action                                                                     | Middleware   |
+--------+-----------+-----------------------------------------------+--------------------+----------------------------------------------------------------------------+--------------+
|        | GET|HEAD  | /                                             |                    | Closure                                                                    | web          |
+========+===========+===============================================+====================+============================================================================+==============+
|        | GET|HEAD  | admin_user                                    | admin_user.index   | \App\Http\Controllers\Admin_userController@index                           | web          |
|        | POST      | admin_user                                    | admin_user.store   | \App\Http\Controllers\Admin_userController@store                           | web          |
|        | GET|HEAD  | admin_user/create                             | admin_user.create  | \App\Http\Controllers\Admin_userController@create                          | web          |
|        | DELETE    | admin_user/{admin_user}                       | admin_user.destroy | \App\Http\Controllers\Admin_userController@destroy                         | web          |
|        | PUT|PATCH | admin_user/{admin_user}                       | admin_user.update  | \App\Http\Controllers\Admin_userController@update                          | web          |
|        | GET|HEAD  | admin_user/{admin_user}                       | admin_user.show    | \App\Http\Controllers\Admin_userController@show                            | web          |
|        | GET|HEAD  | admin_user/{admin_user}/edit                  | admin_user.edit    | \App\Http\Controllers\Admin_userController@edit                            | web          |
|        | GET|HEAD  | admin_user/{id}/delete                        |                    | \App\Http\Controllers\Admin_userController@destroy                         | web          |
|        | GET|HEAD  | admin_user/{id}/deleteMsg                     |                    | \App\Http\Controllers\Admin_userController@DeleteMsg                       | web          |
|        | POST      | admin_user/{id}/update                        |                    | \App\Http\Controllers\Admin_userController@update                          | web          |
+========+===========+===============================================+====================+============================================================================+==============+
|        | GET|HEAD  | api/user                                      |                    | Closure                                                                    | api,auth:api |
|        | GET|HEAD  | dashboard                                     |                    | \App\Http\Controllers\ScaffoldInterface\AppController@dashboard            | web,auth     |
|        | GET|HEAD  | home                                          | home               | App\Http\Controllers\HomeController@index                                  | web,auth     |
|        | GET|HEAD  | login                                         | login              | App\Http\Controllers\Auth\LoginController@showLoginForm                    | web,guest    |
|        | POST      | login                                         |                    | App\Http\Controllers\Auth\LoginController@login                            | web,guest    |
|        | POST      | logout                                        | logout             | App\Http\Controllers\Auth\LoginController@logout                           | web          |
|        | POST      | password/email                                | password.email     | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail      | web,guest    |
|        | POST      | password/reset                                |                    | App\Http\Controllers\Auth\ResetPasswordController@reset                    | web,guest    |
|        | GET|HEAD  | password/reset                                | password.request   | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm     | web,guest    |
|        | GET|HEAD  | password/reset/{token}                        | password.reset     | App\Http\Controllers\Auth\ResetPasswordController@showResetForm            | web,guest    |
|        | GET|HEAD  | permissions                                   |                    | \App\Http\Controllers\ScaffoldInterface\PermissionController@index         | web,auth     |
|        | GET|HEAD  | permissions/create                            |                    | \App\Http\Controllers\ScaffoldInterface\PermissionController@create        | web,auth     |
|        | GET|HEAD  | permissions/delete/{role_id}                  |                    | \App\Http\Controllers\ScaffoldInterface\PermissionController@destroy       | web,auth     |
|        | GET|HEAD  | permissions/edit/{role_id}                    |                    | \App\Http\Controllers\ScaffoldInterface\PermissionController@edit          | web,auth     |
|        | POST      | permissions/store                             |                    | \App\Http\Controllers\ScaffoldInterface\PermissionController@store         | web,auth     |
|        | POST      | permissions/update                            |                    | \App\Http\Controllers\ScaffoldInterface\PermissionController@update        | web,auth     |
|        | GET|HEAD  | register                                      | register           | App\Http\Controllers\Auth\RegisterController@showRegistrationForm          | web,guest    |
|        | POST      | register                                      |                    | App\Http\Controllers\Auth\RegisterController@register                      | web,guest    |
|        | GET|HEAD  | roles                                         |                    | \App\Http\Controllers\ScaffoldInterface\RoleController@index               | web,auth     |
|        | GET|HEAD  | roles/create                                  |                    | \App\Http\Controllers\ScaffoldInterface\RoleController@create              | web,auth     |
|        | GET|HEAD  | roles/delete/{role_id}                        |                    | \App\Http\Controllers\ScaffoldInterface\RoleController@destroy             | web,auth     |
|        | GET|HEAD  | roles/edit/{role_id}                          |                    | \App\Http\Controllers\ScaffoldInterface\RoleController@edit                | web,auth     |
|        | POST      | roles/store                                   |                    | \App\Http\Controllers\ScaffoldInterface\RoleController@store               | web,auth     |
|        | POST      | roles/update                                  |                    | \App\Http\Controllers\ScaffoldInterface\RoleController@update              | web,auth     |
|        | GET|HEAD  | scaffold                                      |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@index          | web          |
|        | GET|HEAD  | scaffold/getAttributes/{table}                |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@getResult      | web          |
|        | GET|HEAD  | scaffold/guidelete/{id}                       |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@deleteMsg      | web          |
|        | POST      | scaffold/guipost                              |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@store          | web          |
|        | GET|HEAD  | scaffold/guirollback/{id}                     |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@destroy        | web          |
|        | POST      | scaffold/manyToMany                           |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@manyToMany     | web          |
|        | GET|HEAD  | scaffold/manyToManyForm                       |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@manyToManyForm | web          |
|        | GET|HEAD  | scaffold/migrate                              |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@migrate        | web          |
|        | GET|HEAD  | scaffold/rollback                             |                    | \Amranidev\ScaffoldInterface\Http\Controllers\GuiController@rollback       | web          |
|        | GET|HEAD  | users                                         |                    | \App\Http\Controllers\ScaffoldInterface\UserController@index               | web,auth     |
|        | POST      | users/addPermission                           |                    | \App\Http\Controllers\ScaffoldInterface\UserController@addPermission       | web,auth     |
|        | POST      | users/addRole                                 |                    | \App\Http\Controllers\ScaffoldInterface\UserController@addRole             | web,auth     |
|        | GET|HEAD  | users/create                                  |                    | \App\Http\Controllers\ScaffoldInterface\UserController@create              | web,auth     |
|        | GET|HEAD  | users/delete/{user_id}                        |                    | \App\Http\Controllers\ScaffoldInterface\UserController@destroy             | web,auth     |
|        | GET|HEAD  | users/edit/{user_id}                          |                    | \App\Http\Controllers\ScaffoldInterface\UserController@edit                | web,auth     |
|        | GET|HEAD  | users/removePermission/{permission}/{user_id} |                    | \App\Http\Controllers\ScaffoldInterface\UserController@revokePermission    | web,auth     |
|        | GET|HEAD  | users/removeRole/{role}/{user_id}             |                    | \App\Http\Controllers\ScaffoldInterface\UserController@revokeRole          | web,auth     |
|        | POST      | users/store                                   |                    | \App\Http\Controllers\ScaffoldInterface\UserController@store               | web,auth     |
|        | POST      | users/update                                  |                    | \App\Http\Controllers\ScaffoldInterface\UserController@update              | web,auth     |
+--------+-----------+-----------------------------------------------+--------------------+----------------------------------------------------------------------------+--------------+
```

## 生成ファイル一覧

### views

- resources/views/admin_user/create.blade.php
- resources/views/admin_user/edit.blade.php
- resources/views/admin_user/index.blade.php
- resources/views/admin_user/show.blade.php

### controllers

- app/Http/Controllers/Admin_userController.php

### models

- app/Admin_user.php

### routes

- routes/web.php

### migrates

- database/migrations/2017_05_31_032551_admin_users.php

### tests

_none_

#### fixtures

_none_

### etc

_none_


## 総感

全体的に過剰な印象。routeは生成されるが、~~GETで@destroyできるようなRESTではない仕様が追加される~~(見間違いだった。）。カーソルでテーブル作成時の名前は`admin_users`だったが、生成されたファイルの殆どは`admin_user`になってしまった。テーブル作成以前のセットアップで大量にscaffold用のファイルがプロジェクトディレクトリに入り込むからか、routeのリストが膨大になる。逆に、many-to-manyやone-to-manyを視覚的に定義できそうなボタンが存在する。また、テーブル間の関連性を図示するgraphなどもある。

逆に、単純なscaffold以外の下記の機能が含まれていて、開発時のscaffoldだけでなく、サービスリリース後のscaffoldも狙いに含んでるのかもしれない

- scaffold models/views/controllersへのアクセスを制限するuser,role,permissionを管理制御
- 画面notificationに対応（オマケ？）

具体的に生成ファイルされたファイル一覧は右記参照。https://github.com/laravel-scaffold-trial/amranidev-scaffold-interface/pull/1


### sqliteでは正常に動かなかった

- 急遽mysqlをセットアップして`php artisan serve`したら接続出来た。laravel5.4はsqliteが使えないのかな・・？
- ユーザを作成してやらないとエラーが出て動かなかった。