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

php artisan make:model  Page -crm

神奇的事情发生啦!

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

你想要的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'],
        ];
    }

相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2021-06-22
  • 2021-07-28
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-12-21
相关资源
相似解决方案