浏览代码

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.
Jens 2 年之前
父节点
当前提交
97f766db27
共有 1 个文件被更改,包括 1 次插入7 次删除
  1. 1 7
      app/Http/Controllers/Admin/UserController.php

+ 1 - 7
app/Http/Controllers/Admin/UserController.php

@@ -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")]