diff --git a/app/Http/Controllers/Api/UserController.php b/app/Http/Controllers/Api/UserController.php index 702be6c3..d9fb64fe 100644 --- a/app/Http/Controllers/Api/UserController.php +++ b/app/Http/Controllers/Api/UserController.php @@ -10,6 +10,7 @@ use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Validation\Rule; +use Illuminate\Validation\ValidationException; class UserController extends Controller { @@ -116,7 +117,10 @@ class UserController extends Controller if($request->credits){ if ($user->credits - $request->credits >= 99999999) throw ValidationException::withMessages([ - 'credits' => "You cannot remove this amount of credits because you would exceed the minimum credit" + 'credits' => "You cannot remove this amount of credits because you would exceed the minimum credit limit" + ]); + elseif($user->credits - $request->credits < 0) throw ValidationException::withMessages([ + 'credits' => "You can't remove this amount of credits because you would exceed the minimum credit limit" ]); $user->decrement('credits', $request->credits); } @@ -125,6 +129,9 @@ class UserController extends Controller if ($user->server_limit - $request->server_limit >= 2147483647) throw ValidationException::withMessages([ 'server_limit' => "You cannot remove this amount of servers because it would exceed the minimum server." ]); + elseif($user->server_limit - $request->server_limit < 0) throw ValidationException::withMessages([ + 'server_limit' => "You cannot remove this amount of servers because it would exceed the minimum server." + ]); $user->decrement('server_limit', $request->server_limit); }