【问题标题】:How to make a migration in laravel module?如何在 laravel 模块中进行迁移?
【发布时间】:2019-11-29 01:21:54
【问题描述】:

在我的 Laravel 项目中,我使用 nwidart 包来制作模块。现在我想将deleted_at 列添加到现有模型中。我应该在我的模块中进行新的迁移。 我该怎么做?

这里是包文档: https://nwidart.com/laravel-modules/v4/advanced-tools/artisan-commands

我想要一些类似的东西用于模块:

php artisan make:migration add_soft_deletes_to_user_table --table="users"

【问题讨论】:

  • 您需要users 表中的数据吗?可以刷新吗?
  • 是的,我需要数据。

标签: laravel module eloquent laravel-migrations


【解决方案1】:

试试这个命令:php artisan module:make-migration add_soft_deletes_to_users_table

然后不要忘记在您的 User 模型上使用 Illuminate\Database\Eloquent\SoftDeletes 特征。

use Illuminate\Database\Eloquent\SoftDeletes;

class User extends Model {

use SoftDeletes;

}

【讨论】:

  • 谢谢。有效。我只是在命令末尾添加模块的名称。
猜你喜欢
  • 2021-08-14
  • 1970-01-01
  • 2019-11-23
  • 2012-02-23
  • 1970-01-01
  • 2016-12-06
  • 2011-01-30
  • 1970-01-01
  • 2019-11-29
相关资源
最近更新 更多