|
|
@@ -40,7 +40,7 @@ class Crud extends Command
|
|
|
protected $intDateSuffix = 'time';
|
|
|
|
|
|
/**
|
|
|
- * 开头后缀
|
|
|
+ * 开关后缀
|
|
|
*/
|
|
|
protected $switchSuffix = 'switch';
|
|
|
|
|
|
@@ -52,7 +52,6 @@ class Crud extends Command
|
|
|
'icon' => 'icon',
|
|
|
'flag' => 'flag',
|
|
|
'url' => 'url',
|
|
|
- 'url' => 'url',
|
|
|
'image' => 'image',
|
|
|
'images' => 'images',
|
|
|
'time' => ['type' => ['int', 'timestamp'], 'name' => 'datetime']
|
|
|
@@ -98,6 +97,7 @@ class Crud extends Command
|
|
|
->addOption('relationprimarykey', 'p', Option::VALUE_OPTIONAL, 'relation primary key', null)
|
|
|
->addOption('mode', 'o', Option::VALUE_OPTIONAL, 'relation table mode,hasone or belongsto', 'belongsto')
|
|
|
->addOption('delete', 'd', Option::VALUE_OPTIONAL, 'delete all files generated by CRUD', null)
|
|
|
+ ->addOption('menu', 'u', Option::VALUE_OPTIONAL, 'create menu when CRUD completed', null)
|
|
|
->setDescription('Build CRUD controller and model from table');
|
|
|
}
|
|
|
|
|
|
@@ -118,6 +118,8 @@ class Crud extends Command
|
|
|
{
|
|
|
throw new Exception('table name can\'t empty');
|
|
|
}
|
|
|
+ //是否生成菜单
|
|
|
+ $menu = $input->getOption("menu");
|
|
|
//关联表
|
|
|
$relation = $input->getOption('relation');
|
|
|
//自定义关联表模型
|
|
|
@@ -204,7 +206,8 @@ class Crud extends Command
|
|
|
}
|
|
|
foreach ($readyFiles as $k => $v)
|
|
|
{
|
|
|
- unlink($v);
|
|
|
+ if (file_exists($v))
|
|
|
+ unlink($v);
|
|
|
}
|
|
|
|
|
|
$output->info("Delete Successed");
|
|
|
@@ -689,6 +692,13 @@ class Crud extends Command
|
|
|
{
|
|
|
throw new Exception("Code: " . $e->getCode() . "\nLine: " . $e->getLine() . "\nMessage: " . $e->getMessage() . "\nFile: " . $e->getFile());
|
|
|
}
|
|
|
+
|
|
|
+ //继续生成菜单
|
|
|
+ if ($menu)
|
|
|
+ {
|
|
|
+ exec("php think menu -c {$controllerUrl}");
|
|
|
+ }
|
|
|
+
|
|
|
$output->info("Build Successed");
|
|
|
}
|
|
|
|