]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/UserController.php
add index option for tech sites
[alttp.git] / app / Http / Controllers / UserController.php
index 8c451fc1328c3260ff6a9ed0c984b353536d917a..da3ebde1bf113bd18e2b56b6fee72ab23a155fd3 100644 (file)
@@ -23,6 +23,21 @@ class UserController extends Controller
                return $user->toJson();
        }
 
+       public function setNickname(Request $request, User $user) {
+               $this->authorize('setNickname', $user);
+
+               $validatedData = $request->validate([
+                       'nickname' => 'string',
+               ]);
+
+               $user->nickname = $validatedData['nickname'];
+               $user->update();
+
+               UserChanged::dispatch($user);
+
+               return $user->toJson();
+       }
+
        public function setStreamLink(Request $request, User $user) {
                $this->authorize('setStreamLink', $user);
 
@@ -43,6 +58,12 @@ class UserController extends Controller
                $this->authorize('view', $user);
                $user->load('participation');
                $user->load('participation.tournament');
+               $user->loadCount('round_first');
+               $user->loadCount('round_second');
+               $user->loadCount('round_third');
+               $user->loadCount('tournament_first');
+               $user->loadCount('tournament_second');
+               $user->loadCount('tournament_third');
                return $user->toJson();
        }