diff --git a/app/Http/Controllers/Admin/PlanController.php b/app/Http/Controllers/Admin/PlanController.php index 2f665fdf..13b7c287 100755 --- a/app/Http/Controllers/Admin/PlanController.php +++ b/app/Http/Controllers/Admin/PlanController.php @@ -21,7 +21,7 @@ class PlanController extends Controller if ($request->input('id')) { $plan = Plan::find($request->input('id')); if (!$plan) { - abort(500, '套餐ID不存在'); + abort(500, '套餐不存在'); } } else { $plan = new Plan(); diff --git a/app/Http/Controllers/Admin/ServerController.php b/app/Http/Controllers/Admin/ServerController.php index 0092dcb8..1211be96 100755 --- a/app/Http/Controllers/Admin/ServerController.php +++ b/app/Http/Controllers/Admin/ServerController.php @@ -21,6 +21,9 @@ class ServerController extends Controller public function save (ServerSave $request) { if ($request->input('id')) { $server = Server::find($request->input('id')); + if (!$server) { + abort(500, '服务器不存在'); + } } else { $server = new Server(); } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index cabde760..e84e745f 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -27,20 +27,23 @@ class UserController extends Controller public function save (UserSave $request) { if ($request->input('id')) { - $userModel = User::find($request->input('id')); + $user = User::find($request->input('id')); + if (!$user) { + abort(500, '用户不存在'); + } } else { - $userModel = new User(); + $user = new User(); } if (User::where('email', $request->input('email')->first())) { abort(500, '邮箱已被使用'); } - $userModel->email = $request->input('email'); - $userModel->password = password_hash($request->input('password'), PASSWORD_DEFAULT); - $userModel->transfer_enable = $request->input('transfer_enable') * 1073741824; - $userModel->expired_at = $request->input('expired_at'); - $userModel->banned = $request->input('banned'); - $userModel->is_admin = $request->input('is_admin'); - if (!$userModel->save()) { + $user->email = $request->input('email'); + $user->password = password_hash($request->input('password'), PASSWORD_DEFAULT); + $user->transfer_enable = $request->input('transfer_enable') * 1073741824; + $user->expired_at = $request->input('expired_at'); + $user->banned = $request->input('banned'); + $user->is_admin = $request->input('is_admin'); + if (!$user->save()) { abort(500, '保存失败'); } return response([