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

Bra*_*iac 3 laravel

正如标题所说;有没有办法删除/恢复/回滚运行时创建的文件的创建php artisan make:model MyModel -mcr

就像是:

php artisan destroy:model MyModel

..它“级联”删除所有相关文件?

DAV*_*AYI 6

只需手动完成,在撰写本文时没有命令

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

对我有用,希望能帮到你!


Dav*_*vit 4

当你跑步时

php artisan make:model --help
Run Code Online (Sandbox Code Playgroud)

你必须看到的命令

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
Run Code Online (Sandbox Code Playgroud)

这意味着默认情况下它是不可能的。你必须为它制定你自己的工匠命令。另外,如果您想了解 artisan 命令选项和参数,请使用

php artisan command_name --help
Run Code Online (Sandbox Code Playgroud)