Laravel 5.4-在哪里更改登录ID [英] Laravel 5.4 - Where to change the id for login
问题描述
在身份验证期间,它使用了错误的ID,所以我遇到了以下错误:
SQLSTATE[42S22]: Column not found: 1054 Field'id' unknow in where clause (SQL: select * from "acteur" where "id" = 22 limit 1
During authentification it use the wrong id so i have this error :
SQLSTATE[42S22]: Column not found: 1054 Field'id' unknow in where clause (SQL: select * from "acteur" where "id" = 22 limit 1
正确的ID是:id_biodiv_acteur
.表acteur
的模型是User.php
The right id is : id_biodiv_acteur
. And the model for the table acteur
is User.php
所以我做了这些改变:
在Authenticable
,User
,LoginController
中,我做了protected $primaryKey = 'id_biodiv_acteur';
.
在GenericUser
中,我这样做了:
In Authenticable
, User
, LoginController
i did protected $primaryKey = 'id_biodiv_acteur';
.
In GenericUser
i did this :
public function getAuthIdentifierName()
{
return 'id_biodiv_acteur';
}
但是它不起作用.
如果我在数据库表中放了id
而不是id_biodiv_acteur
,它可以工作,但是我想保留正确的ID.
But it's not working.
If in the table of my database I put id
instead of id_biodiv_acteur
it work, but i want to keep the right id.
如果需要查看一些代码,请问我.
Ask me if you need to see some code.
感谢您的帮助!
推荐答案
在您的用户模型中,我认为您需要设置protected $primaryKey = 'id_biodiv_acteur';
In your user model which I think in your case is the "acteur" model you need to set protected $primaryKey = 'id_biodiv_acteur';
这篇关于Laravel 5.4-在哪里更改登录ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!