方式一($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);
});