我试图从更改默认的主键id
的users
表userId
,但Laravel认证机制始终检查id
从users
表.例:
Users :: check()和Users :: attempt()
这些函数总是检查表的id
属性users
,如何改变Laravel的这种行为.
小智 5
要覆盖用于搜索的主键,必须在User模型上定义primaryKey属性.
protected $primaryKey = 'userId';
Run Code Online (Sandbox Code Playgroud)