方式一($user->id无法获取则增id需使用insertGetId获取自增id )
$this->startTrans();
try {
$this->commit();
} catch (\Exception $e) {
$this->rollback();
}
方式二($user->id 可获取自增id)
$res = $this->transaction(function () use ($group,$post) {
//删除
return $group->delete();
//编辑
return $group->allowField('group_name')->isUpdate(true)->save($post);
//保存
return $group->allowField('group_name')->save($post);
});