Skip to content

Commit

Permalink
Added code for new settings and updates
Browse files Browse the repository at this point in the history
Added new filters and updated them so that there is a single select game type and multi select game type filter for the pages where there is only 1 option to pick or multiple options to pick

Also added build type

This should be fully working now
  • Loading branch information
Zemill committed Dec 7, 2023
1 parent e1fff17 commit 49f40cc
Show file tree
Hide file tree
Showing 48 changed files with 194 additions and 103 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
22 changes: 17 additions & 5 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,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 Down
51 changes: 37 additions & 14 deletions app/Services/GlobalDataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@

class GlobalDataService
{
private $filtersMinimumPatch;

public function __construct()
{
//can add modifier here for patreons to reduce what they can filter on
$this->filtersMinimumPatch = '2.53.0.83004';

}

public function getHeaderAlert()
Expand Down Expand Up @@ -84,6 +81,12 @@ public function getDefaultBuildType()
{
if (Auth::check()) {
$user = Auth::user();


$talentbuildtype = $user->userSettings->firstWhere('setting', 'talentbuildtype');

return $talentbuildtype ? $talentbuildtype->value : 'Popular';

}

return 'Popular';
Expand Down Expand Up @@ -236,21 +239,28 @@ public function getAdvancedFilterShowDefault()
}


public function getGameTypeDefault()
public function getGameTypeDefault($type)
{

if (Auth::check()) {
$user = Auth::user();

$gameTypeSetting = $user->userSettings->firstWhere('setting', 'game_type');

if ($gameTypeSetting) {
$gameTypeValue = $gameTypeSetting->value;

return explode(',', $gameTypeSetting->value);
if($type == "single"){
$gameTypeSetting = $user->userSettings->firstWhere('setting', 'game_type');
if ($gameTypeSetting) {
return [$gameTypeSetting->value];
}
}else{
$gameTypeSetting = $user->userSettings->firstWhere('setting', 'multi_game_type');
if ($gameTypeSetting) {
$gameTypeValue = $gameTypeSetting->value;

return explode(',', $gameTypeSetting->value);
}
}
}


}
return ['sl'];
}

Expand All @@ -261,6 +271,15 @@ public function getDefaultSeason()

public function getFilterData()
{
$filtersMinimumPatch = '2.53.0.83004';
if (Auth::check()) {
$user = Auth::user();

if($this->checkIfSiteFlair($user->blizz_id, $user->region) || $this->isOwner($user->blizz_id, $user->region)){
$filtersMinimumPatch = '2.52.0.81700';
}
}

$filterData = new \stdClass;

$filterData->timeframe_type = [
Expand All @@ -269,15 +288,15 @@ public function getFilterData()
];

$filterData->timeframes = SeasonGameVersion::select('game_version')
->where('game_version', '>=', $this->filtersMinimumPatch)
->where('game_version', '>=', $filtersMinimumPatch)
->orderBy('game_version', 'DESC')
->get()
->map(function ($item) {
return ['code' => $item->game_version, 'name' => $item->game_version];
});

$filterData->timeframes_grouped = SeasonGameVersion::select('game_version')
->where('game_version', '>=', $this->filtersMinimumPatch)
->where('game_version', '>=', $filtersMinimumPatch)
->orderBy('game_version', 'DESC')
->get()
->groupBy(function ($date) {
Expand Down Expand Up @@ -696,4 +715,8 @@ public function checkIfSiteFlair($blizz_id, $region)

return false;
}

public function isOwner($blizz_id, $region){
return ($blizz_id == 67280 and $region == 1) ? true : false;
}
}
3 changes: 2 additions & 1 deletion resources/js/components/Filtering/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
:values="filters.talent_build_types"
:text="'Talent Build Type'"
@input-changed="handleInputChange"
:defaultValue="filters.talent_build_types[0].code"
:defaultValue="buildtypedefault"
></single-select-filter>

<!-- Minimum Games -->
Expand Down Expand Up @@ -302,6 +302,7 @@
advancedfiltering: Boolean,
defaultHero: Number,
defaultRole: String,
buildtypedefault: String,
},
data(){
Expand Down
Loading

0 comments on commit 49f40cc

Please sign in to comment.