소스 검색

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",
             "credits" => "required|numeric|min:0|max:99999999",
             "server_limit" => "required|numeric|min:0|max:1000000",
             "server_limit" => "required|numeric|min:0|max:1000000",
             "role" => Rule::in(['admin', 'mod', 'client', 'member']),
             "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'])) {
         if (isset($this->pterodactyl->getUser($request->input('pterodactyl_id'))['errors'])) {
             throw ValidationException::withMessages([
             throw ValidationException::withMessages([
                 'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")]
                 'pterodactyl_id' => [__("User does not exists on pterodactyl's panel")]