Update UserController.php

Fixes an issue when you update a user, it's impossible to update it, the check for referral_code is invalid.

Fixed:
- Deletes the custom check and uses laravel's check to ensure it's valid.
This commit is contained in:
Jens 2022-07-19 20:27:16 +02:00 committed by GitHub
parent 801568c404
commit 97f766db27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -123,15 +123,9 @@ class UserController extends Controller
"credits" => "required|numeric|min:0|max:99999999",
"server_limit" => "required|numeric|min:0|max:1000000",
"role" => Rule::in(['admin', 'mod', 'client', 'member']),
"referral_code" => "required|string|min:2|max:32",
"referral_code" => "required|string|min:2|max:32|unique:users,referral_code,{$user->id}",
]);
if (User::where('referral_code', '=', $request->input('referral_code'))->exists()) {
throw ValidationException::withMessages([
'referral_code' => [__("Another User with this Referral-Code already exists!")]
]);
}
if (isset($this->pterodactyl->getUser($request->input('pterodactyl_id'))['errors'])) {
throw ValidationException::withMessages([
'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")]