laravel 快速创建数据库表Migration/Controller/Model 到指定目录

以前在创建数据库表Migration,Model和Controller 分三步执行,现发现一条命令就可以搞定,超级赞,不过注意生成的文件都是到默认的目录下,如果需要到指定位置,还得分开写(Hppt/Models/Page)

php artisan make:model  Page -crm

神奇的事情发生啦!

你想要的Model,Migration,Controller都有啦!!!

它们的路径如下

model: app/Page.php

Controller: app/Http/Controller/PageController.php

MIgration: database/migrations/2018_11_30_073634_create_pages_table.php

通过查看Illuminate\Foundation\Console\ModelMakeCommand.php文件,我们可以看到-crm分别对应的意思

protected function getOptions()
    {
        return [
            ['all', 'a', InputOption::VALUE_NONE, 'Generate a migration, factory, and resource controller for the model'],
            //c 创建一个controller
            ['controller', 'c', InputOption::VALUE_NONE, 'Create a new controller for the model'],

            ['factory', 'f', InputOption::VALUE_NONE, 'Create a new factory for the model'],

            ['force', null, InputOption::VALUE_NONE, 'Create the class even if the model already exists'],
            // m 创建一个migration文件
            ['migration', 'm', InputOption::VALUE_NONE, 'Create a new migration file for the model'],

            ['pivot', 'p', InputOption::VALUE_NONE, 'Indicates if the generated model should be a custom intermediate table model'],
            // r  设置controller文件的权限
            ['resource', 'r', InputOption::VALUE_NONE, 'Indicates if the generated controller should be a resource controller'],
        ];
    }
posted @ 2018-11-30 15:43  MrBear  阅读(1133)  评论(0编辑  收藏  举报