Skip to content

Commit

Permalink
Merge pull request #580 from Heroes-Profile/develop
Browse files Browse the repository at this point in the history
Heroes Profile v0.5.3
  • Loading branch information
Zemill authored Dec 7, 2023
2 parents 4970a53 + 204bc77 commit 4b5ed53
Show file tree
Hide file tree
Showing 51 changed files with 330 additions and 130 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/CompareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function show(Request $request, $hero = null)
'regions' => $this->globalDataService->getRegionIDtoString(),
'userinput' => $userinput,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),
]);
}

Expand Down
5 changes: 0 additions & 5 deletions app/Http/Controllers/Esports/EsportsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ public function show(Request $request)
return view('Esports.esportsMain')
->with([
'regions' => $this->globalDataService->getRegionIDtoString(),
//'filters' => $this->globalDataService->getFilterData(),
//'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
//'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
//'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
//'defaultbuildtype' => $this->globalDataService->getDefaultBuildType()
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function show(Request $request)
->with([
'regions' => $this->globalDataService->getRegionIDtoString(),
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Global/GlobalDraftController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function show(Request $request, $hero = null)
'regions' => $this->globalDataService->getRegionIDtoString(),
'userinput' => $userinput,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function show(Request $request, $hero = null)
'regions' => $this->globalDataService->getRegionIDtoString(),
'userinput' => $userinput,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function show(Request $request, $hero = null, $allyenemy = null)
'regions' => $this->globalDataService->getRegionIDtoString(),
'userinput' => $userinput,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function show(Request $request, $hero = null, $allyenemy = null)
'regions' => $this->globalDataService->getRegionIDtoString(),
'heroes' => $this->globalDataService->getHeroes(),
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Global/GlobalHeroStatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function show(Request $request)
->with([
'regions' => $this->globalDataService->getRegionIDtoString(),
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function show(Request $request)
return view('Global.Leaderboard.globalLeaderboard')->with([
'regions' => $this->globalDataService->getRegionIDtoString(),
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaultseason' => (string) $this->globalDataService->getDefaultSeason(),
'weekssincestart' => $this->globalDataService->getWeeksSinceSeasonStart(),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Global/GlobalPartyStatsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function show(Request $request)
->with([
'regions' => $this->globalDataService->getRegionIDtoString(),
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function show(Request $request, $hero = null)
'regions' => $this->globalDataService->getRegionIDtoString(),
'userinput' => $userinput,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function show(Request $request, $hero = null)
'heroes' => $this->globalDataService->getHeroes(),
'userinput' => $userinput,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'defaulttimeframetype' => $this->globalDataService->getDefaultTimeframeType(),
'advancedfiltering' => $this->globalDataService->getAdvancedFilterShowDefault(),
'defaulttimeframe' => [$this->globalDataService->getDefaultTimeframe()],
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Player/FriendFoeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'season' => $season,
'game_type' => $game_type,
'game_map' => $game_map,
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'filters' => $this->globalDataService->getFilterData(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
]);
Expand Down
6 changes: 1 addition & 5 deletions app/Http/Controllers/Player/PlayerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'region' => 'required|integer',
];

if (request()->has('game_type')) {
$validationRules['game_type'] = ['sometimes', 'nullable', new GameTypeInputValidation()];
}
if (request()->has('season')) {
$validationRules['season'] = ['sometimes', 'nullable', new SeasonInputValidation()];
}
Expand Down Expand Up @@ -64,7 +61,6 @@ public function show(Request $request, $battletag, $blizz_id, $region)
}

$season = $request['season'];
$game_type = $request['game_type'];

return view('Player.player')->with([
'regions' => $this->globalDataService->getRegionIDtoString(),
Expand All @@ -73,7 +69,7 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'blizz_id' => $blizz_id,
'region' => $region,
'season' => $season,
'game_type' => $game_type,
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),
'filters' => $this->globalDataService->getFilterData(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
]);
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Player/PlayerHeroesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function showAll(Request $request, $battletag, $blizz_id, $region)
'region' => $region,
'filters' => $this->globalDataService->getFilterData(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
]);

}
Expand Down Expand Up @@ -73,6 +74,7 @@ public function showSingle(Request $request, $battletag, $blizz_id, $region, $he
'filters' => $this->globalDataService->getFilterData(),
'regions' => $this->globalDataService->getRegionIDtoString(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Player/PlayerMMRController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'blizz_id' => $blizz_id,
'region' => $region,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
]);
}
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Player/PlayerMapsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function showAll(Request $request, $battletag, $blizz_id, $region)
'region' => $region,
'filters' => $this->globalDataService->getFilterData(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),

]);
}

Expand Down Expand Up @@ -76,6 +78,8 @@ public function showSingle(Request $request, $battletag, $blizz_id, $region, $ma
'filters' => $this->globalDataService->getFilterData(),
'regions' => $this->globalDataService->getRegionIDtoString(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),

]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Player/PlayerMatchHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'blizz_id' => $blizz_id,
'region' => $region,
'filters' => $this->globalDataService->getFilterData(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
]);
}
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Player/PlayerMatchupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'region' => $region,
'filters' => $this->globalDataService->getFilterData(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),

]);
}

Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Player/PlayerRolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function showAll(Request $request, $battletag, $blizz_id, $region)
'region' => $region,
'filters' => $this->globalDataService->getFilterData(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),

]);
}

Expand Down Expand Up @@ -66,6 +68,8 @@ public function showSingle(Request $request, $battletag, $blizz_id, $region, $ro
'filters' => $this->globalDataService->getFilterData(),
'regions' => $this->globalDataService->getRegionIDtoString(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("single"),

]);
}
}
1 change: 1 addition & 0 deletions app/Http/Controllers/Player/PlayerTalentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function show(Request $request, $battletag, $blizz_id, $region)
'talentimages' => $this->globalDataService->getPreloadTalentImageUrls(),
'patreon' => $this->globalDataService->checkIfSiteFlair($blizz_id, $region),
'heroes' => $this->globalDataService->getHeroes(),
'gametypedefault' => $this->globalDataService->getGameTypeDefault("multi"),
]);
}

Expand Down
35 changes: 30 additions & 5 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use App\Models\Hero;
use App\Models\PatreonAccount;
use App\Rules\GameTypeInputValidation;
use App\Rules\TalentBuildTypeInputValidation;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
Expand All @@ -31,6 +33,7 @@ public function saveSettings(Request $request)
$validationRules = [
'userhero' => 'nullable|numeric',
'usergametype' => ['sometimes', 'nullable', new GameTypeInputValidation()],
'talentbuildtype' => ['sometimes', 'nullable', new TalentBuildTypeInputValidation()],
];

$validator = Validator::make($request->all(), $validationRules);
Expand Down Expand Up @@ -59,21 +62,33 @@ public function saveSettings(Request $request)
['value' => $userhero]
);
}

if (! is_null($request['usergametype'])) {
$user = BattlenetAccount::find($request['userid']);

$userGameTypes = $request['usergametype'];
$usergametype = $request['usergametype'];

$user->userSettings()->updateOrCreate(
['setting' => 'game_type'],
['value' => $usergametype]
);
}


if (! is_null($request['usermultigametype'])) {
$user = BattlenetAccount::find($request['userid']);

$userGameTypes = $request['usermultigametype'];
$existingGameTypes = GameType::whereIn('short_name', $userGameTypes)->pluck('short_name')->all();
if (count($existingGameTypes) === count($userGameTypes)) {
$usergametype = $request['usergametype'];
$usergametype = $request['usermultigametype'];
} else {
return ['success' => false];
}

$user->userSettings()->updateOrCreate(
['setting' => 'game_type'],
['value' => implode(',', $usergametype)]
['setting' => 'multi_game_type'],
['value' => implode(',', $userGameTypes)]
);
}

Expand All @@ -88,6 +103,16 @@ public function saveSettings(Request $request)
);
}

if (! is_null($request['talentbuildtype'])) {
$user = BattlenetAccount::find($request['userid']);

$talentbuildtype = $request['talentbuildtype'];

$user->userSettings()->updateOrCreate(
['setting' => 'talentbuildtype'],
['value' => $talentbuildtype]
);
}
return ['success' => true];
}

Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\SetGlobalDataValues::class,
];

/**
Expand Down
27 changes: 27 additions & 0 deletions app/Http/Middleware/SetGlobalDataValues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Middleware;

use App\Services\GlobalDataService;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class SetGlobalDataValues
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
$globalDataService = new GlobalDataService();
$globalDataService->calculateMaxReplayNumber();
$globalDataService->getLatestPatch();
$globalDataService->getLatestGameDate();
$globalDataService->getHeaderAlert();

return $next($request);
}
}
Loading

0 comments on commit 4b5ed53

Please sign in to comment.