$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();
两张表关联,主表我要更新一条数据,关联表我需要新增一条数据,怎么用关联模型一步到位实现? 面代码我尝试实现不了,求大神指点。。。
分两步做,1.更新数据 2.新增