Update UserController.php

This commit is contained in:
António Duarte 2021-07-25 19:19:59 +01:00 committed by GitHub
parent 87f57af510
commit dbf389e717
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -78,7 +78,11 @@ class UserController extends Controller
$request->validate([
"credits" => "required|numeric|min:0|max:1000000",
]);
if ($request->user()->credits + $request->credits >= 99999999) throw ValidationException::withMessages([
'code' => "You can't add this amount of credits because you would exceed the credit limit"
]);
$user->increment('credits', $request->credits);
return $user;