public function load()
 {
     BGGData::getUserInfos();
     $arrayRawGamesOwned = BGGData::getGamesOwned();
     BGGData::getDetailOwned($arrayRawGamesOwned);
     BGGData::getGamesAndExpansionsOwned();
     BGGData::getGamesRated();
     BGGData::getPlays();
 }
 public function ajaxTableLastAcquisition($username, $page)
 {
     $arrayRawGamesOwned = BGGData::getGamesOwned();
     $arrayGamesDetails = BGGData::getDetailOwned($arrayRawGamesOwned);
     $arrayRawGamesAndExpansionsOwned = BGGData::getGamesAndExpansionsOwned();
     Stats::getCollectionArrays($arrayRawGamesOwned);
     Stats::getOwnedRelatedArrays($arrayGamesDetails);
     Stats::getAcquisitionRelatedArrays($arrayRawGamesAndExpansionsOwned);
     $params['lastAcquisition'] = $this->getLastAcquisition($page);
     $params['userinfo'] = UserInfos::getUserInformations(BGGData::getUserInfos());
     return \View::make('partials.lines-table-last-games-acquisition', $params);
 }
 public function game($username, $idGame)
 {
     $paramsMenu = Page::getMenuParams();
     $arrayRawUserInfos = BGGData::getUserInfos();
     $arrayUserInfos = UserInfos::getUserInformations($arrayRawUserInfos);
     $params['userinfo'] = $arrayUserInfos;
     $arrayGameDetail = BGGData::getDetailOfGame($idGame);
     $arrayGameDetail = Stats::convertBggDetailInfo($arrayGameDetail);
     $arrayGameDetail = array_merge($arrayGameDetail, Stats::getDetailInfoGame($arrayGameDetail));
     $arrayRawGamesPlays = BGGData::getPlays();
     $arrayRawGamesOwned = BGGData::getGamesOwned();
     $arrayGamesDetails = BGGData::getDetailOwned($arrayRawGamesOwned);
     $arrayRawGamesAndExpansionsOwned = BGGData::getGamesAndExpansionsOwned();
     Stats::getCollectionArrays($arrayRawGamesOwned);
     Stats::getOwnedRelatedArrays($arrayGamesDetails);
     Stats::getOwnedExpansionLink($arrayRawGamesAndExpansionsOwned);
     if (isset($GLOBALS['data']['gamesCollection'][$idGame])) {
         $arrayGameDetail['collection'] = $GLOBALS['data']['gamesCollection'][$idGame];
     }
     Stats::getPlaysRelatedArrays($arrayRawGamesPlays);
     if (isset($GLOBALS['data']['arrayTotalPlays'][$idGame])) {
         $arrayGameDetail['numplays'] = count($GLOBALS['data']['arrayTotalPlays'][$idGame]);
         $allPlays = $GLOBALS['data']['arrayTotalPlays'][$idGame]['plays'];
         if ($allPlays) {
             uasort($allPlays, 'App\\Lib\\Utility::compareDate');
             $arrayGameDetail['lastPlayed']['date'] = $allPlays[0]['date'];
             $arrayGameDetail['lastPlayed']['since'] = Carbon::createFromTimestamp($allPlays[0]['date'])->diffForHumans();
             $arrayGameDetail['plays'] = $allPlays;
         } else {
             $arrayGameDetail['lastPlayed'] = '';
         }
     } else {
         $arrayGameDetail['numplays'] = 0;
         $arrayGameDetail['lastPlayed'] = '';
         $arrayGameDetail['plays'] = [];
     }
     $params['game'] = $arrayGameDetail;
     $params = array_merge($params, $paramsMenu);
     return \View::make('game', $params);
 }
 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);
 }
 /**
  * @param $page
  * @return array
  */
 private function getAcquisitionByMonthArray($page)
 {
     $arrayRawGamesAndExpansionsOwned = BGGData::getGamesAndExpansionsOwned();
     Stats::getAcquisitionRelatedArrays($arrayRawGamesAndExpansionsOwned);
     $acquisitionArray = Graphs::getAcquisitionByMonth($page);
     return $acquisitionArray;
 }