$user = \app\index\model\User::find($uid); $user->totalpoint = $details['integral'] + $user['totalpoint']; $user->comment->uid = $uid; $user->comment->type = 4; $user->comment->bid = $id; $user->comment->content = '观看文章获取'; $user->comment->num = $details['integral']; $user->together('comments')->save();
Two tables are related. I want to update a piece of data in the main table, and I need to add a new piece of data in the related table. How can I use the related model to achieve this in one step? I can't implement the above code, please give me some advice. . .