Laravel中使用数据库自动事务

try{
DB::transaction(function () use ($orderParser, $json, $e_poi) {
   $order = $orderParser->parse($json);
   event(new OrderPushed($order, Carbon::now(), $e_poi['poi_id'], $json['order']['orderId'], $json));
});
}catch(\Illuminate\Database\QueryException $ex){
 return back() -> with(['info' => '抱歉,修改失败,请稍后重试!']);
}

return redirect('admin/buy/supplier') -> with(['info' => '修改成功']);

猜你喜欢

转载自blog.csdn.net/qq_16014497/article/details/80861436