public function tobuy()
 {
     $arrayRawUserInfos = BGGData::getUserInfos();
     $arrayRawGamesOwned = BGGData::getGamesOwned();
     $arrayRawGamesPreviouslyOwned = BGGData::getGamesPreviouslyOwned();
     $arrayGamesDetails = BGGData::getDetailOwned($arrayRawGamesOwned);
     $arrayRawGamesRated = BGGData::getGamesRated();
     $arrayRawGamesPlays = BGGData::getPlays();
     $arrayGamesHot = BGGData::getHotWithDetails();
     $arrayUserInfos = UserInfos::getUserInformations($arrayRawUserInfos);
     Stats::getRatedRelatedArrays($arrayRawGamesRated);
     Stats::getCollectionArrays($arrayRawGamesOwned);
     Stats::getCollectionArrays($arrayRawGamesPreviouslyOwned, 'gamesPrevOwned');
     Stats::getOwnedRelatedArrays($arrayGamesDetails);
     Stats::getPlaysRelatedArrays($arrayRawGamesPlays);
     $params['userinfo'] = $arrayUserInfos;
     $gamesToBuy = [];
     // High rated
     $highRating = [];
     foreach ($GLOBALS['data']['gamesRated'] as $idGame => $ratedGame) {
         if (!isset($GLOBALS['data']['gamesCollection'][$idGame]) && !isset($GLOBALS['data']['gamesPrevOwned'][$idGame])) {
             $highRating[$idGame] = $ratedGame;
         }
     }
     uasort($highRating, 'App\\Lib\\Utility::compareOrderRating');
     $highRating = array_slice($highRating, 0, 50, true);
     foreach ($highRating as &$game) {
         $game['weight'] = $game['rating'];
         $game['rating'] .= ' / 10';
     }
     Utility::normalizeArray($highRating, 'weight');
     $this->compileGameArray($gamesToBuy, $highRating, 'Bien classé', 1, 'rating');
     // Played frequently
     $playsFrequently = [];
     foreach ($GLOBALS['data']['arrayTotalPlays'] as $idGame => $game) {
         if (!isset($GLOBALS['data']['gamesCollection'][$idGame]) && !isset($GLOBALS['data']['gamesPrevOwned'][$idGame])) {
             $playsFrequently[$idGame] = $game;
         }
     }
     usort($playsFrequently, 'App\\Lib\\Utility::compareOrderNbPlayed');
     $playsFrequently = array_slice($playsFrequently, 0, 50, true);
     foreach ($playsFrequently as &$game) {
         $game['weight'] = $game['nbPlayed'];
         $game['nbPlayed'] .= ' parties';
     }
     Utility::normalizeArray($playsFrequently, 'weight');
     $this->compileGameArray($gamesToBuy, $playsFrequently, 'Joué souvent', 1, 'nbPlayed');
     // Game hot of the same author
     $gameWithDesignerHot = [];
     $mostDesigner = Graphs::getMostDesignerOwned();
     foreach ($arrayGamesHot as $idGame => $game) {
         if (!isset($GLOBALS['data']['gamesCollection'][$idGame]) && !isset($GLOBALS['data']['gamesPrevOwned'][$idGame])) {
             if (isset($game['detail']['boardgamedesigner'])) {
                 foreach ($game['detail']['boardgamedesigner'] as $hotDesigner) {
                     if (isset($mostDesigner[$hotDesigner['id']])) {
                         $gameWithDesignerHot[$idGame] = $game;
                         $gameWithDesignerHot[$idGame]['weight'] = $mostDesigner[$hotDesigner['id']]['nbOwned'];
                         $gameWithDesignerHot[$idGame]['designer'] = $mostDesigner[$hotDesigner['id']]['name'];
                     }
                 }
             }
         }
     }
     Utility::normalizeArray($gameWithDesignerHot, 'weight');
     $this->compileGameArray($gamesToBuy, $gameWithDesignerHot, 'Jeu d\'un auteur apprécié', 1, 'designer');
     usort($gamesToBuy, 'App\\Lib\\Utility::compareOrderWeight');
     $params['games'] = $gamesToBuy;
     return \View::make('rapports_tobuy', $params);
 }
Esempio n. 2
0
 /**
  * @param $page
  * @return array
  */
 private function getAcquisitionByMonthArray($page)
 {
     $arrayRawGamesAndExpansionsOwned = BGGData::getGamesAndExpansionsOwned();
     Stats::getAcquisitionRelatedArrays($arrayRawGamesAndExpansionsOwned);
     $acquisitionArray = Graphs::getAcquisitionByMonth($page);
     return $acquisitionArray;
 }