diff --git a/app/Http/Controllers/Admin/CouponController.php b/app/Http/Controllers/Admin/CouponController.php index 8c500985..1ef78bab 100644 --- a/app/Http/Controllers/Admin/CouponController.php +++ b/app/Http/Controllers/Admin/CouponController.php @@ -34,7 +34,9 @@ class CouponController extends Controller abort(500, '创建失败'); } } else { - if (!Coupon::find($request->input('id'))->update($params)) { + try { + Coupon::find($request->input('id'))->update($params); + } catch (\Exception $e) { abort(500, '保存失败'); } } diff --git a/app/Http/Controllers/Admin/NoticeController.php b/app/Http/Controllers/Admin/NoticeController.php index 9b24f97e..f80ba7c5 100644 --- a/app/Http/Controllers/Admin/NoticeController.php +++ b/app/Http/Controllers/Admin/NoticeController.php @@ -29,7 +29,9 @@ class NoticeController extends Controller abort(500, '保存失败'); } } else { - if (!Notice::find($request->input('id'))->update($data)) { + try { + Notice::find($request->input('id'))->update($data); + } catch (\Exception $e) { abort(500, '保存失败'); } } diff --git a/app/Http/Controllers/Admin/OrderController.php b/app/Http/Controllers/Admin/OrderController.php index 726f178d..c245f5de 100644 --- a/app/Http/Controllers/Admin/OrderController.php +++ b/app/Http/Controllers/Admin/OrderController.php @@ -59,7 +59,9 @@ class OrderController extends Controller abort(500, '订单不存在'); } - if (!$order->update($updateData)) { + try { + $order->update($updateData); + } catch (\Exception $e) { abort(500, '更新失败'); } diff --git a/app/Http/Controllers/Admin/PlanController.php b/app/Http/Controllers/Admin/PlanController.php index fe6f1960..a787e35a 100755 --- a/app/Http/Controllers/Admin/PlanController.php +++ b/app/Http/Controllers/Admin/PlanController.php @@ -30,9 +30,10 @@ class PlanController extends Controller } DB::beginTransaction(); // update user group id - User::where('plan_id', $plan->id) - ->update(['group_id' => $plan->group_id]); - if (!$plan->update($params)) { + try { + User::where('plan_id', $plan->id)->update(['group_id' => $plan->group_id]); + $plan->update($params); + } catch (\Exception $e) { DB::rollBack(); abort(500, '保存失败'); } @@ -79,7 +80,10 @@ class PlanController extends Controller if (!$plan) { abort(500, '该订阅不存在'); } - if (!$plan->update($updateData)) { + + try { + $plan->update($updateData); + } catch (\Exception $e) { abort(500, '保存失败'); } diff --git a/app/Http/Controllers/Admin/ServerController.php b/app/Http/Controllers/Admin/ServerController.php index 47f96352..996f8667 100755 --- a/app/Http/Controllers/Admin/ServerController.php +++ b/app/Http/Controllers/Admin/ServerController.php @@ -64,7 +64,9 @@ class ServerController extends Controller if (!$server) { abort(500, '服务器不存在'); } - if (!$server->update($params)) { + try { + $server->update($params); + } catch (\Exception $e) { abort(500, '保存失败'); } return response([ @@ -163,7 +165,9 @@ class ServerController extends Controller if (!$server) { abort(500, '该服务器不存在'); } - if (!$server->update($params)) { + try { + $server->update($params); + } catch (\Exception $e) { abort(500, '保存失败'); } diff --git a/app/Http/Controllers/Admin/TutorialController.php b/app/Http/Controllers/Admin/TutorialController.php index 2c9bd0f7..b20967bc 100644 --- a/app/Http/Controllers/Admin/TutorialController.php +++ b/app/Http/Controllers/Admin/TutorialController.php @@ -25,7 +25,9 @@ class TutorialController extends Controller abort(500, '创建失败'); } } else { - if (!Tutorial::find($request->input('id'))->update($params)) { + try { + Tutorial::find($request->input('id'))->update($params); + } catch (\Exception $e) { abort(500, '保存失败'); } } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 82d53f75..91824a19 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -79,7 +79,10 @@ class UserController extends Controller } $params['group_id'] = $plan->group_id; } - if (!$user->update($params)) { + + try { + $user->update($params); + } catch (\Exception $e) { abort(500, '保存失败'); } return response([ diff --git a/app/Http/Controllers/User/UserController.php b/app/Http/Controllers/User/UserController.php index b728f744..fddb91b2 100755 --- a/app/Http/Controllers/User/UserController.php +++ b/app/Http/Controllers/User/UserController.php @@ -132,7 +132,9 @@ class UserController extends Controller if (!$user) { abort(500, '该用户不存在'); } - if (!$user->update($updateData)) { + try { + $user->update($updateData); + } catch (\Exception $e) { abort(500, '保存失败'); }