fix elq update try catch

This commit is contained in:
Tokumeikoi 2020-03-17 14:28:47 +08:00
parent 7bb4852cca
commit 96f562a9e7
8 changed files with 33 additions and 12 deletions

View File

@ -34,7 +34,9 @@ class CouponController extends Controller
abort(500, '创建失败'); abort(500, '创建失败');
} }
} else { } else {
if (!Coupon::find($request->input('id'))->update($params)) { try {
Coupon::find($request->input('id'))->update($params);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
} }

View File

@ -29,7 +29,9 @@ class NoticeController extends Controller
abort(500, '保存失败'); abort(500, '保存失败');
} }
} else { } else {
if (!Notice::find($request->input('id'))->update($data)) { try {
Notice::find($request->input('id'))->update($data);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
} }

View File

@ -59,7 +59,9 @@ class OrderController extends Controller
abort(500, '订单不存在'); abort(500, '订单不存在');
} }
if (!$order->update($updateData)) { try {
$order->update($updateData);
} catch (\Exception $e) {
abort(500, '更新失败'); abort(500, '更新失败');
} }

View File

@ -30,9 +30,10 @@ class PlanController extends Controller
} }
DB::beginTransaction(); DB::beginTransaction();
// update user group id // update user group id
User::where('plan_id', $plan->id) try {
->update(['group_id' => $plan->group_id]); User::where('plan_id', $plan->id)->update(['group_id' => $plan->group_id]);
if (!$plan->update($params)) { $plan->update($params);
} catch (\Exception $e) {
DB::rollBack(); DB::rollBack();
abort(500, '保存失败'); abort(500, '保存失败');
} }
@ -79,7 +80,10 @@ class PlanController extends Controller
if (!$plan) { if (!$plan) {
abort(500, '该订阅不存在'); abort(500, '该订阅不存在');
} }
if (!$plan->update($updateData)) {
try {
$plan->update($updateData);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }

View File

@ -64,7 +64,9 @@ class ServerController extends Controller
if (!$server) { if (!$server) {
abort(500, '服务器不存在'); abort(500, '服务器不存在');
} }
if (!$server->update($params)) { try {
$server->update($params);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
return response([ return response([
@ -163,7 +165,9 @@ class ServerController extends Controller
if (!$server) { if (!$server) {
abort(500, '该服务器不存在'); abort(500, '该服务器不存在');
} }
if (!$server->update($params)) { try {
$server->update($params);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }

View File

@ -25,7 +25,9 @@ class TutorialController extends Controller
abort(500, '创建失败'); abort(500, '创建失败');
} }
} else { } else {
if (!Tutorial::find($request->input('id'))->update($params)) { try {
Tutorial::find($request->input('id'))->update($params);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
} }

View File

@ -79,7 +79,10 @@ class UserController extends Controller
} }
$params['group_id'] = $plan->group_id; $params['group_id'] = $plan->group_id;
} }
if (!$user->update($params)) {
try {
$user->update($params);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
return response([ return response([

View File

@ -132,7 +132,9 @@ class UserController extends Controller
if (!$user) { if (!$user) {
abort(500, '该用户不存在'); abort(500, '该用户不存在');
} }
if (!$user->update($updateData)) { try {
$user->update($updateData);
} catch (\Exception $e) {
abort(500, '保存失败'); abort(500, '保存失败');
} }