You can use the push method to recursively save the model object and its relationship. So you might want to do something like:
DB::transaction(function () use ($lead, $comment) {
$lead->fill([
//some attributes to be updated.
]);
$comment->fill(['lead_id' => $lead->id]);
$lead->push();
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…