📜  laravel 从插入中获取 ID - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:14.047000             🧑  作者: Mango

代码示例4
$user = User::create([
    'username' => $data['username'] . ' ' . $data['username2'],
    'mail' => $data['mail'],
    'password' => bcrypt($data['password']),
]);

$userInfo = UserInformation::create([
    'user_id' => $user->id,
    'current_food' => $food,
    'current_level' => $level,
]);