且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel 5.4,重命名用户表列

更新时间:2023-12-01 08:55:28

OP的答案.

删除代码protected $primaryKey = 'login'getAuthIdentifierName()方法.

您要做的就是在控制器中重写(添加)username()方法.

All you have to do is override (add) username() method in the controller.

有关迁移及其正确操作的说明:

Note for migrations and how to do it right:

  1. 始终使用迁移来创建和更新数据库架构
  2. 如果您是唯一的开发人员 ,并且没有设置没有生产环境,只需修改迁移并重置数据库即可(删除所有表格)+迁移
  3. 如果您是团队已经建立了生产环境,请始终创建新的迁移
  4. down()方法不那么在意
  1. always use migrations to create and update database schema
  2. if you are a lone developer AND there is no production environment set up, just amend the migrations and do database reset (remove all tables) + migrate
  3. if you are a team OR there is production environment already set up, always create new migration
  4. do not bother with down() method that much

创作者&的一些材料您可以在此播客 http://www上收听Laravel的有关迁移的朋友.laravelpodcast.com/episodes/68236-episode-53-bigger-better 大约30分钟.

Some material from creator & friends of Laravel regarding migrations can be heard in this podcast http://www.laravelpodcast.com/episodes/68236-episode-53-bigger-better around 30 minute mark.