I have AuthController
in Laravel and I have 2 tables, one is Users
and one is Users_Information
and I want to insert into Users_Information
upon登记。
所以我想从下面的方法中获取 id 并插入一个新行并将该行的列 ID 设置为我刚刚创建的用户的 ID。
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'username' => $data['username'] . ' ' . $data['username2'],
'mail' => $data['mail'],
'password' => bcrypt($data['password']),
]);
}
我想在 Users_Information
中插入一列 id
, current_food
和 current_level
I have a controller for the Users_Information
called UserInformation
, would I just call UserInformation::create
but how would I get the id from the User::create
?
原文由 TheGod39 发布,翻译遵循 CC BY-SA 4.0 许可协议
请记住,如果您使用自定义 ID 设置表,则必须在代码中指明。就我而言,我的表“Antecedentes”具有自定义 ID“ant_id”,因此“id”不起作用,必须像这样放置“ant_id”:
我可以继续。