diff --git a/dist/app/Http/Controllers/Web/Admin/Tools/UsersController.php b/dist/app/Http/Controllers/Web/Admin/Tools/UsersController.php index d536123..7739862 100644 --- a/dist/app/Http/Controllers/Web/Admin/Tools/UsersController.php +++ b/dist/app/Http/Controllers/Web/Admin/Tools/UsersController.php @@ -3,6 +3,9 @@ namespace App\Http\Controllers\Web\Admin\Tools; use App\Enums\Auth\Permissions; +use App\Enums\Game\Characters; +use App\Enums\Game\Runner; +use App\Http\Requests\Api\Admin\UserDetails\EditUserRequest; use App\Models\User\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\View; @@ -43,4 +46,31 @@ public function details(User $user) 'user' => $user, ]); } + + public function edit(User $user, EditUserRequest $request) + { + $playerData = $user->playerData(); + + $playerData->currency_a = $request->currencyA; + $playerData->currency_b = $request->currencyB; + $playerData->currency_c = $request->currencyC; + + $playerData->last_faction = $request->lastFaction; + $playerData->last_runner = $request->lastRunner; + $playerData->last_hunter = $request->lastHunter; + + $playerData->has_played_dg_1 = $request->hasPlayedDG1; + $playerData->hunter_faction_level = $request->hunterFactionLevel; + $playerData->runner_faction_level = $request->runnerFactionLevel; + + $playerData->save(); + + foreach (Characters::cases() as $character) { + $characterData = $playerData->characterDataForCharacter($character); + $characterData->level = $request->{'level'.$character->value}; + $characterData->save(); + } + + return redirect()->back(); + } } diff --git a/dist/app/Http/Requests/Api/Admin/UserDetails/EditUserRequest.php b/dist/app/Http/Requests/Api/Admin/UserDetails/EditUserRequest.php new file mode 100644 index 0000000..38e3cb5 --- /dev/null +++ b/dist/app/Http/Requests/Api/Admin/UserDetails/EditUserRequest.php @@ -0,0 +1,99 @@ +can(Permissions::EDIT_USERS->value); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array|string> + */ + public function rules(): array + { + return [ + 'currencyA' => 'int|required', + 'currencyB' => 'int|required', + 'currencyC' => 'int|required', + 'lastFaction' => ['required', Rule::enum(Faction::class)], + 'lastRunner' => ['required', Rule::enum(Runner::class)], + 'lastHunter' => ['required', Rule::enum(Hunter::class)], + 'runnerFactionLevel' => 'int|min:1', + 'SmokeLevel' => 'int|min:1', + 'InkLevel' => 'int|min:1', + 'GhostLevel' => 'int|min:1', + 'SawbonesLevel' => 'int|min:1', + 'SwitchLevel' => 'int|min:1', + 'DashLevel' => 'int|min:1', + 'hunterFactionLevel' => 'int|min:1', + 'StalkerFactionLevel' => 'int|min:1', + 'PoacherFactionLevel' => 'int|min:1', + 'InquisitorFactionLevel' => 'int|min:1', + 'MassLevel' => 'int|min:1', + ]; + } + + public function passedValidation() + { + $this->currencyA = $this->input('currencyA'); + $this->currencyB = $this->input('currencyB'); + $this->currencyC = $this->input('currencyC'); + + $this->lastFaction = Faction::tryFrom($this->input('lastFaction')); + $this->lastRunner = Runner::tryFrom($this->input('lastRunner')); + $this->lastHunter = Hunter::tryFrom($this->input('lastHunter')); + + $this->hasPlayedDG1 = $this->input('hasPlayedDG1', false); + + $this->runnerFactionLevel = $this->input('runnerFactionLevel'); + + foreach(Runner::cases() as $runner) { + $this->{'level'.$runner->value} = $this->input($runner->value.'Level'); + } + + $this->hunterFactionLevel = $this->input('hunterFactionLevel'); + + foreach (Hunter::cases() as $hunter) { + $this->{'level'.$hunter->value} = $this->input($hunter->value.'Level'); + } + } +} diff --git a/dist/resources/views/admin/tools/user-details.blade.php b/dist/resources/views/admin/tools/user-details.blade.php index e126cc9..58f6ef2 100644 --- a/dist/resources/views/admin/tools/user-details.blade.php +++ b/dist/resources/views/admin/tools/user-details.blade.php @@ -15,192 +15,201 @@ use App\Models\User\PlayerData; $allowEdit = $user->can(\App\Enums\Auth\Permissions::EDIT_USERS->value); - $allowEdit = true; @endphp
-
-

General Info

-
- Avatar -
-
- - {{ $user->id }} -
-
- - {{ $user->steam_id }} -
-
- - {{ $user->last_known_username }} -
-
- - {{ $user->created_at }} -
-
- - {{ $user->source }} + @if($allowEdit)
@csrf @endif +
+

General Info

+
+ Avatar +
+
+ + {{ $user->id }} +
+
+ + {{ $user->steam_id }} +
+
+ + {{ $user->last_known_username }} +
+
+ + {{ $user->created_at }} +
+
+ + {{ $user->source }} +
-
-
-

Player Data

-
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->currency_a }} - @endif +
+

Player Data

+
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->currency_a }} + @endif +
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->currency_b }} + @endif +
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->currency_c }} + @endif +
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->currency_b }} - @endif +
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->last_faction }} + @endif +
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->last_runner }} + @endif +
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->last_hunter }} + @endif +
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->currency_c }} - @endif +
+
+ + @if($allowEdit) + + @else + {{ $user->playerData()->has_played_dg_1 ? 'Yes' : 'No' }} + @endif +
-
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->last_faction }} - @endif +
+

Progression

+
+
+ + @if($allowEdit) + + @else + {{ number_format($user->playerData()->runner_faction_level, thousands_separator: '.') }} + @endif +
+ + @foreach(Runner::cases() as $character) + + @endforeach
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->last_runner }} - @endif +
+
+ + @if($allowEdit) + + @else + {{ number_format($user->playerData()->hunter_faction_level, thousands_separator: '.') }} + @endif +
+ + @foreach(Hunter::cases() as $character) + + @endforeach
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->last_hunter }} - @endif + +
+ + Save Changes +
-
-
- - @if($allowEdit) - - @else - {{ $user->playerData()->has_played_dg_1 ? 'Yes' : 'No' }} - @endif -
-
-
-
-

Progression

-
-
- - @if($allowEdit) - - @else - {{ number_format($user->playerData()->runner_faction_level, thousands_separator: '.') }} - @endif -
- - @foreach(Runner::cases() as $character) - - @endforeach -
-
-
- - @if($allowEdit) - - @else - {{ number_format($user->playerData()->hunter_faction_level, thousands_separator: '.') }} - @endif -
- - @foreach(Hunter::cases() as $character) - - @endforeach -
-
+ @if($allowEdit)@endif
\ No newline at end of file diff --git a/dist/resources/views/components/misc/progression/character-progression.blade.php b/dist/resources/views/components/misc/progression/character-progression.blade.php index 5a02e4e..4ca0f86 100644 --- a/dist/resources/views/components/misc/progression/character-progression.blade.php +++ b/dist/resources/views/components/misc/progression/character-progression.blade.php @@ -15,6 +15,7 @@ class="w-20" id="{{ $character->character->value }}Level" name="{{ $character->character->value }}Level" value="{{ $character->level }}" + min="1" /> @else {{ $character->level }} diff --git a/dist/routes/admin.php b/dist/routes/admin.php index b1b5aef..40532dc 100644 --- a/dist/routes/admin.php +++ b/dist/routes/admin.php @@ -21,6 +21,7 @@ Route::get('users', [UsersController::class, 'index'])->name(UsersController::class); Route::get('users/{user}', [UsersController::class, 'details'])->name('user.details'); +Route::post('user/{user}/edit', [UsersController::class, 'edit'])->name('user.edit'); Route::fallback(function () { return redirect(route('admin.dashboard'));