# CURD命令大全
`EasyAdmin`框架以內置快速生成CURD的命令, 包括控制器、視圖、模型、JS文件。能夠使開發者效率得到進一步提升。
> 備注:在進行CURD命令行之前, 請按照規范設計表結構, 請參數`表結構規范`模塊說明。
# 常用命令
~~~
# 生成ea_test_goods表的CURD
php think curd -t test_goods
# 生成ea_test_goods表的CURD, 文件沖突時強制覆蓋
php think curd -t test_goods -f 1
# 刪除ea_test_goods表的CURD
php think curd -t test_goods -d 1
# 生成ea_test_goods表的CURD, 控制器在目錄demo下的Goods.php文件
php think curd -t test_goods -c demo/Goods
# 生成ea_test_goods表的CURD, 模型在目錄demo下的Goods.php文件
php think curd -t test_goods -m demo/Goods
# 生成ea_test_goods表的CURD, 并關聯ea_test_cate表, 并設置外鍵為cate_id
php think curd -t test_goods -r test_cate --foreignKey=cate_id --primaryKey=id
# 生成ea_test_goods表的CURD, 并關聯ea_test_cate表, 并設置只顯示title,image兩個字段
php think curd -t test_goods -r test_cate --foreignKey=cate_id --relationOnlyFileds=title,image
# 生成ea_test_goods表的CURD, 并關聯ea_test_cate表, 并設置主表外鍵cate_id在表單的下拉選擇顯示的關聯表的title字段
php think curd -t test_goods -r test_cate --foreignKey=cate_id --relationBindSelect=title
# 生成ea_test_goods表的CURD, 并設置logo字段后綴為單圖片
php think curd -t test_goods --imageFieldSuffix=logo
# 生成ea_test_goods表的CURD, 并設置忽略remark, stock字段
php think curd -t test_goods --ignoreFields=remark --ignoreFields=stock
~~~
# 參數介紹
| 短參 | 長參 | 說明 |
| --- | --- | --- |
| \-t | \--table=VALUE | 主表名 |
| \-c | \--controllerFilename=VALUE | 控制器文件名 |
| \-m | \--modelFilename=VALUE | 主表模型文件名 |
| \-f | \--force=VALUE | 強制覆蓋模式 |
| \-d | \--delete=VALUE | 刪除模式 |
| | \--checkboxFieldSuffix=VALUE | 復選框字段后綴 |
| | \--radioFieldSuffix=VALUE | 單選框字段后綴 |
| | \--imageFieldSuffix=VALUE | 單圖片字段后綴 |
| | \--imagesFieldSuffix=VALUE | 多圖片字段后綴 |
| | \--fileFieldSuffix=VALUE | 單文件字段后綴 |
| | \--filesFieldSuffix=VALUE | 多文件字段后綴 |
| | \--dateFieldSuffix=VALUE | 時間字段后綴 |
| | \--switchFields=VALUE | 開關的字段 |
| | \--selectFileds=VALUE | 下拉的字段 |
| | \--editorFields=VALUE | 富文本的字段 |
| | \--sortFields=VALUE | 排序的字段 |
| | \--ignoreFields=VALUE | 忽略的字段 |
| \-r | \--relationTable=VALUE | 關聯表名 |
| | \--foreignKey=VALUE | 關聯外鍵 |
| | \--primaryKey=VALUE | 關聯主鍵 |
| | \--relationOnlyFileds=VALUE | 關聯模型中只顯示的字段 |
| | \--relationBindSelect=VALUE | 關聯模型中的字段用于主表外鍵的表單下拉選擇 |
| | \--relationModelFilename=VALUE | 關聯模型文件名 |