public static function getMenuParams() { $params = []; if (isset($GLOBALS['parameters']['general']['username'])) { $params['username'] = $GLOBALS['parameters']['general']['username']; } if (!SessionManager::ifBggInfo() && Auth::check()) { $params['name'] = Auth::user()->name; } return $params; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $GLOBALS['parameters']['cache']['level'] = ''; SessionManager::manageConnexionInfo($request->route()->username); if (!isset($GLOBALS['parameters']['general']['username'])) { return redirect('/login'); } else { $GLOBALS['parameters']['cache']['level'] = BGGData::getLevelOfLoading(); } return $next($request); }
public function home() { $params = []; if (SessionManager::ifBggInfo()) { $arrayRawUserInfos = BGGData::getUserInfos(); $arrayBuddies = UserInfos::formatArrayUserInfo($arrayRawUserInfos, 'buddies', 'buddy'); $arrayGamesTop = UserInfos::formatArrayUserInfo($arrayRawUserInfos, 'top', 'item'); $arrayUserInfos = UserInfos::getUserInformations($arrayRawUserInfos); $params['userinfo'] = $arrayUserInfos; $params['userinfo']['lists']['buddies'] = $arrayBuddies; $params['userinfo']['lists']['topGames'] = $arrayGamesTop; } $paramsMenu = Page::getMenuParams(); $params = array_merge($params, $paramsMenu); return \View::make('home', $params); }
public function home() { $paramsMenu = Page::getMenuParams(); $arrayRawUserInfos = BGGData::getUserInfos(); $arrayRawGamesOwned = BGGData::getGamesOwned(); $arrayGamesDetails = BGGData::getDetailOwned($arrayRawGamesOwned); $arrayRawGamesAndExpansionsOwned = BGGData::getGamesAndExpansionsOwned(); $arrayRawGamesPlays = BGGData::getPlays(); Stats::getPlaysRelatedArrays($arrayRawGamesPlays); Stats::getCollectionArrays($arrayRawGamesOwned); Stats::getOwnedRelatedArrays($arrayGamesDetails); Stats::getAcquisitionRelatedArrays($arrayRawGamesAndExpansionsOwned); $params['lastPlayed'] = $this->getLastPlays(); if (SessionManager::ifLoginAsSelf()) { $params['lastAcquisition'] = $this->getLastAcquisition(); } else { $params['lastAcquisition'] = []; } $arrayUserInfos = UserInfos::getUserInformations($arrayRawUserInfos); $params['userinfo'] = $arrayUserInfos; $params = array_merge($params, $paramsMenu); return \View::make('summary', $params); }
public static function ifBGGInfo() { return SessionManager::ifBggInfo(); }
public function vendre() { $arrayRawUserInfos = BGGData::getUserInfos(); $arrayRawGamesAndExpansionsOwned = BGGData::getGamesAndExpansionsOwned(); $arrayRawGamesOwned = BGGData::getGamesOwned(); $arrayUserInfos = UserInfos::getUserInformations($arrayRawUserInfos); $arrayRawGamesPlays = BGGData::getPlays(); $arrayRawGamesRated = BGGData::getGamesRated(); Stats::getPlaysRelatedArrays($arrayRawGamesPlays); Stats::getAcquisitionRelatedArrays($arrayRawGamesAndExpansionsOwned); Stats::getRatedRelatedArrays($arrayRawGamesRated); Stats::getCollectionArrays($arrayRawGamesOwned); $params['userinfo'] = $arrayUserInfos; $gamesToSell = []; $nbToGetInEachCategory = floor(count($GLOBALS['data']['gamesCollection']) / 5); // Less rentable if (SessionManager::ifLoginAsSelf()) { $arrayRentable = Stats::getRentabiliteCollection(); $lessRentable = array_reverse(array_slice($arrayRentable, count($arrayRentable) - $nbToGetInEachCategory)); foreach ($lessRentable as &$game) { $game['rentabilite'] = round($game['rentabilite'], 2) . ' $ par partie'; } $this->compileGameArray($gamesToSell, $lessRentable, 'Moins rentable', 1, 'rentabilite'); } // Played since $gameLessTimePlayed = Stats::getCollectionTimePlayed(); $mostTimeSincePlayed = array_slice($gameLessTimePlayed, 0, $nbToGetInEachCategory); foreach ($mostTimeSincePlayed as &$game) { if (!$game['since']) { $game['since'] = 'jamais'; } } $this->compileGameArray($gamesToSell, $mostTimeSincePlayed, 'Joué depuis longtemps', 1, 'since'); // Less played $lessPlayed = $GLOBALS['data']['gamesCollection']; usort($lessPlayed, 'App\\Lib\\Utility::compareNumPlays'); $lessPlayed = array_slice($lessPlayed, 0, $nbToGetInEachCategory); foreach ($lessPlayed as &$game) { if ($game['numplays'] == 0) { $game['numplays'] = 'jamais'; } else { $game['numplays'] . ' parties'; } } $this->compileGameArray($gamesToSell, $lessPlayed, 'Moins joués', 1, 'numplays'); // Less rated $arrayRated = Stats::getRatedCollection(); $lessRated = array_reverse(array_slice($arrayRated, count($arrayRated) - $nbToGetInEachCategory)); foreach ($lessRated as &$game) { $game['rating'] .= ' / 10'; } $this->compileGameArray($gamesToSell, $lessRated, 'Moins bien classé', 1, 'rating'); usort($gamesToSell, 'App\\Lib\\Utility::compareOrderWeight'); $params['games'] = $gamesToSell; return \View::make('rapports_vendre', $params); }
public function home() { $paramsMenu = Page::getMenuParams(); // Games owned $arrayRawGamesOwned = BGGData::getGamesOwned(); Stats::getCollectionArrays($arrayRawGamesOwned); Stats::getOwnedRelatedArrays(BGGData::getDetailOwned($arrayRawGamesOwned)); unset($arrayRawGamesOwned); // Games and expansions owned Stats::getAcquisitionRelatedArrays(BGGData::getGamesAndExpansionsOwned()); // Games played Stats::getPlaysRelatedArrays(BGGData::getPlays()); // Games rated Stats::getRatedRelatedArrays(BGGData::getGamesRated()); // User infos $arrayUserInfos = UserInfos::getUserInformations(BGGData::getUserInfos()); $totalPlayGameCollection = 0; $totalGameOwnedNotPlayed = 0; foreach ($GLOBALS['data']['gamesCollection'] as $idGame => $game) { if (isset($GLOBALS['data']['arrayTotalPlays'][$idGame])) { $totalPlayGameCollection += $GLOBALS['data']['arrayTotalPlays'][$idGame]['nbPlayed']; } else { $totalGameOwnedNotPlayed++; } } $params['userinfo'] = $arrayUserInfos; $params['stats']['nbGamesOwned'] = count($GLOBALS['data']['gamesCollection']); $params['stats']['nbGamesAndExpansionsOwned'] = $GLOBALS['data']['nbGamesAndExpansionsOwned']; $params['stats']['nbPlaysTotal'] = $GLOBALS['data']['countAllPlays']; $params['stats']['nbPlaysDifferentGame'] = count($GLOBALS['data']['arrayTotalPlays']); $params['stats']['averagePlayByMonth'] = 0; $params['stats']['averagePlayDifferentByMonth'] = 0; if (count($GLOBALS['data']['arrayPlaysByMonth']) > 0) { $params['stats']['averagePlayByMonth'] = round($GLOBALS['data']['countAllPlays'] / count($GLOBALS['data']['arrayPlaysByMonth'])); $params['stats']['averagePlayDifferentByMonth'] = round(count($GLOBALS['data']['arrayTotalPlays']) / count($GLOBALS['data']['arrayPlaysByMonth'])); } $params['stats']['hindex'] = $GLOBALS['data']['hindex']; $params['stats']['averageAcquisitionByMonth'] = ''; if (SessionManager::ifLoginAsSelf()) { if (count($GLOBALS['data']['acquisitionsByMonth']) > 0) { $params['stats']['averageAcquisitionByMonth'] = round($GLOBALS['data']['totalWithAcquisitionDate'] / count($GLOBALS['data']['acquisitionsByMonth'])); } } $params['stats']['averageValueGames'] = ''; $params['stats']['totalValueGames'] = ''; if (SessionManager::ifLoginAsSelf()) { if (count($GLOBALS['data']['arrayValuesGames']) > 0) { $params['stats']['averageValueGames'] = Utility::displayMoney($GLOBALS['data']['totalGamesValue'] / count($GLOBALS['data']['arrayValuesGames'])); } $params['stats']['totalValueGames'] = Utility::displayMoney($GLOBALS['data']['totalGamesValue']); } $params['stats']['nbPlayAveragePlayCollectionGame'] = round($totalPlayGameCollection / count($GLOBALS['data']['gamesCollection']), 2); $params['stats']['nbPlayAverageByDay'] = 0; $params['stats']['nbPlayDifferentAverageByDay'] = 0; if (isset($GLOBALS['data']['nbDaysSinceFirstPlay'])) { $params['stats']['nbPlayAverageByDay'] = round($GLOBALS['data']['countAllPlays'] / $GLOBALS['data']['nbDaysSinceFirstPlay'], 2); $params['stats']['nbPlayDifferentAverageByDay'] = round(count($GLOBALS['data']['arrayTotalPlays']) / $GLOBALS['data']['nbDaysSinceFirstPlay'], 2); } $params['stats']['nbGameOwnedNotPlayed'] = $totalGameOwnedNotPlayed; if (count($GLOBALS['data']['gamesCollection']) > 0) { $params['stats']['percentGameOwnedNotPlayed'] = Utility::displayPercent(round($totalGameOwnedNotPlayed / count($GLOBALS['data']['gamesCollection']) * 100, 2)); } $params['graphs']['byMonth'] = Graphs::getPlayByMonth(); $params['graphs']['byYear'] = Graphs::getPlayByYear(); $params['graphs']['byDayWeek'] = Graphs::getPlayByDayWeek(); $params['graphs']['mostPlayed'] = Graphs::getMostPlayed(); $params['graphs']['nbPlayer'] = Graphs::getNbPlayerCollection(); $params['graphs']['acquisitionByMonth'] = Graphs::getAcquisitionByMonth(); $params['graphs']['mostType'] = Graphs::getMostType(); $params['graphs']['playsByRating'] = Graphs::getPlayByRating(); $params['graphs']['playsByLength'] = Graphs::getPlayByLength(); $params['table']['ownedTimePlayed'] = Graphs::getOwnedTimePlayed(); $params['table']['mostDesigner'] = Graphs::getMostDesignerOwned(); $params['table']['ownedRentable'] = Graphs::getOwnedRentable(); $params = array_merge($params, $paramsMenu); return \View::make('stats', $params); }