public function showIndex() { // Prepare some summarized totals for the home view to display in the // widgets // EVE Online Server Information $server = EveServerServerStatus::find(1); // Key Information // If the user has 0 keys, we can 0 all of the values // If the user has keys, determine values only applicable to // this users keys if (!\Auth::isSuperUser()) { if (count(Session::get('valid_keys')) > 0) { $total_keys = SeatKey::whereIn('keyID', Session::get('valid_keys'))->count(); $total_characters = EveCharacterCharacterSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->count(); $total_corporations = EveCorporationCorporationSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.corporationID', '=', 'corporation_corporationsheet.corporationID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '=', 'Corporation')->count(); $total_char_isk = EveCharacterCharacterSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->sum('balance'); $total_corp_isk = EveCorporationAccountBalance::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.corporationID', '=', 'corporation_accountbalance.corporationID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '=', 'Corporation')->where('accountKey', '!=', EveCorporationAccountBalance::Dust_Account_Key)->sum('balance'); $total_skillpoints = EveCharacterCharacterSheetSkills::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet_skills.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->sum('skillpoints'); } else { $total_keys = $total_characters = $total_corporations = $total_char_isk = $total_corp_isk = $total_skillpoints = 0; } } else { // Super user gets all of the data! $total_keys = SeatKey::count(); $total_characters = EveCharacterCharacterSheet::count(); $total_corporations = EveCorporationCorporationSheet::count(); $total_char_isk = EveCharacterCharacterSheet::sum('balance'); $total_corp_isk = EveCorporationAccountBalance::where('accountKey', '!=', EveCorporationAccountBalance::Dust_Account_Key)->sum('balance'); $total_skillpoints = EveCharacterCharacterSheetSkills::sum('skillpoints'); } return View::make('home')->with('server', $server)->with('total_keys', $total_keys)->with('total_characters', $total_characters)->with('total_corporations', $total_corporations)->with('total_char_isk', $total_char_isk)->with('total_corp_isk', $total_corp_isk)->with('total_skillpoints', $total_skillpoints); }
public static function Update() { BaseApi::bootstrap(); $scope = 'Server'; $api = 'ServerStatus'; // Lock the call so that we are the only instance of this running now() // If it is already locked, just return without doing anything if (!BaseApi::isLockedCall($api, $scope)) { $lockhash = BaseApi::lockCall($api, $scope); } else { return; } // Do the call $pheal = new Pheal(); try { $server_status = $pheal->serverScope->ServerStatus(); } catch (Exception $e) { throw $e; } if (!BaseApi::checkDbCache($scope, $api, $server_status->cached_until)) { // Update the Database $existing_status = \EveServerServerStatus::find(1); if (isset($existing_status)) { // Update the ServerStatus $existing_status->currentTime = $server_status->request_time; $existing_status->serverOpen = $server_status->serverOpen; $existing_status->onlinePlayers = $server_status->onlinePlayers; $existing_status->save(); } else { // Create a ServerStatus entry \EveServerServerStatus::create(array('currentTime' => $server_status->request_time, 'serverOpen' => $server_status->serverOpen, 'onlinePlayers' => $server_status->onlinePlayers)); } // Update the cached_until time in the database for this api call BaseApi::setDbCache($scope, $api, $server_status->cached_until); } // Unlock the call BaseApi::unlockCall($lockhash); return $server_status; }