代码之家  ›  专栏  ›  技术社区  ›  Brainmaniac

在单个artisan命令中删除模型、控制器和迁移?

  •  0
  • Brainmaniac  · 技术社区  · 6 年前

    php artisan make:model MyModel -mcr ?

    比如:

    php artisan destroy:model MyModel

    1 回复  |  直到 6 年前
        1
  •  3
  •   Davit Zeynalyan    6 年前

    当你跑的时候

    php artisan make:model --help
    

    Usage:
      make:model [options] [--] <name>
    
    Arguments:
      name                  The name of the class
    
    Options:
      -a, --all             Generate a migration, factory, and resource controller for the model
      -c, --controller      Create a new controller for the model
      -f, --factory         Create a new factory for the model
          --force           Create the class even if the model already exists
      -m, --migration       Create a new migration file for the model
      -p, --pivot           Indicates if the generated model should be a custom intermediate table model
      -r, --resource        Indicates if the generated controller should be a resource controller
      -h, --help            Display this help message
      -q, --quiet           Do not output any message
      -V, --version         Display this application version
          --ansi            Force ANSI output
          --no-ansi         Disable ANSI output
      -n, --no-interaction  Do not ask any interactive question
          --env[=ENV]       The environment the command should run under
      -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose outp
    ut and 3 for debug
    

    这意味着它是不可能的。你必须自己动手指挥。如果您想了解artisan命令选项和参数,还可以使用

    php artisan command_name --help
    
        2
  •  6
  •   DAVID AJAYI    5 年前

    只需手动操作,在撰写本文时没有命令

    1. 先删除模型(如果不需要)再删除模型
    2. ...database/migrations 文件夹
    3. 如果您已经迁移,即如果您已经运行 php artisan migrate ,登录到您的phpmyadmin或SQL(无论哪种情况),并在数据库中删除迁移创建的表
    4. 仍然在数据库的migrations文件夹中,找到具有该迁移文件名的行,然后删除该行。

    对我有用,希望有帮助!