/** * Run the Update * * @return mixed|void */ public function call() { // TODO: Check if we have access to char/characterSheet // and ship this updater as we already have everything $pheal = $this->setScope('char')->getPheal(); foreach ($this->api_info->characters as $character) { $result = $pheal->Skills(['characterID' => $character->characterID]); // Get the CharacterSheet Data $character_data = CharacterSheetModel::firstOrNew(['characterID' => $character->characterID]); // .. and update it with the freeSkillPoints $character_data->fill(['freeSkillPoints' => $result->freeSkillPoints]); $character_data->save(); // Next up, Skills. Skills themselves never go away, but // obviously update as time goes by. So, lets update or // create them as needed foreach ($result->skills as $skill) { $skill_info = CharacterSheetSkills::firstOrNew(['characterID' => $character->characterID, 'typeID' => $skill->typeID]); $skill_info->fill(['skillpoints' => $skill->skillpoints, 'level' => $skill->level, 'published' => $skill->published]); $skill_info->save(); } // Foreach Skills } // Foreach Character return; }
/** * Gets a user's main character sheet. * * @param \Seat\Web\Models\User $user * @param string $service * * @return \Seat\Eveapi\Models\Character\CharacterSheet */ private function getMainCharacter(User $user, $service) { // Get the character id from the user's settings. $characterID = $user->settings->where('name', 'main_character_id')->first(); $characterID = $characterID ? $characterID->value : false; // Get the character sheet of the main character if the character exists in $characters. $characters = $this->getValidCharacters($user, $service); $character = $characters->whereLoose('characterID', $characterID)->first(); $character = $character ? $this->character_sheets->where('characterID', $character->characterID)->first() : false; return $character; }
/** * @param $character_id * * @return \Illuminate\Http\JsonResponse */ public function getCharacterSkillsCoverageChartData($character_id) { if ($character_id == 1) { return response()->json([]); } $data = $this->getCharacterSkillCoverage($character_id); $character = CharacterSheet::where('characterID', $character_id)->first(); return response()->json(['labels' => $data->map(function ($item) { return $item->marketGroupName; })->toArray(), 'datasets' => [['label' => $character->name, 'data' => $data->map(function ($item) { return round($item->characterAmount / $item->gameAmount * 100, 2); // character / in game rate })->toArray(), 'fill' => true, 'backgroundColor' => 'rgba(60,141,188,0.3)', 'borderColor' => '#3c8dbc', 'pointBackgroundColor' => '#3c8dbc', 'pointBorderColor' => '#fff']]]); }
/** * Run the Update * * @return mixed|void */ public function call() { // TODO: Check if we have access to char/characterSheet // and ship this updater as we already have everything $pheal = $this->setScope('char')->getPheal(); foreach ($this->api_info->characters as $character) { $result = $pheal->Clones(['characterID' => $character->characterID]); // Get the CharacterSheet Data $character_data = CharacterSheetModel::firstOrNew(['characterID' => $character->characterID]); // .. and update it $character_data->fill(['DoB' => $result->DoB, 'race' => $result->race, 'bloodLineID' => $result->bloodLineID, 'bloodLine' => $result->bloodLine, 'ancestryID' => $result->ancestryID, 'ancestry' => $result->ancestry, 'gender' => $result->gender, 'freeRespecs' => $result->freeRespecs, 'cloneJumpDate' => $result->cloneJumpDate, 'lastRespecDate' => $result->lastRespecDate, 'lastTimedRespec' => $result->lastTimedRespec, 'remoteStationDate' => $result->remoteStationDate, 'jumpActivation' => $result->jumpActivation, 'jumpFatigue' => $result->jumpFatigue, 'jumpLastUpdate' => $result->jumpLastUpdate, 'intelligence' => $result->attributes->intelligence, 'memory' => $result->attributes->memory, 'charisma' => $result->attributes->charisma, 'perception' => $result->attributes->perception, 'willpower' => $result->attributes->willpower]); $character_data->save(); // Next up, Implants. We need to clear up the ones // that we already know of as implants can change // at any given time. CharacterSheetImplants::where('characterID', $character->characterID)->delete(); // Lets loop over the implants and create them foreach ($result->implants as $implant) { CharacterSheetImplants::create(['characterID' => $character->characterID, 'typeID' => $implant->typeID, 'typeName' => $implant->typeName]); } // Foreach Implants // Next up, Jump Clones. Because we know that Clones can // change at any moment, we will have to take the ones // we know of and remove them, and then re-add what // we got from the API CharacterSheetJumpClone::where('characterID', $character->characterID)->delete(); CharacterSheetJumpCloneImplants::where('characterID', $character->characterID)->delete(); // Lets loop over the clones for the character. foreach ($result->jumpClones as $jump_clone) { CharacterSheetJumpClone::create(['characterID' => $character->characterID, 'jumpCloneID' => $jump_clone->jumpCloneID, 'typeID' => $jump_clone->typeID, 'locationID' => $jump_clone->locationID, 'cloneName' => $jump_clone->cloneName]); } // Foreach JumpClone // Lets loop over the Jump Clone Implants for the character foreach ($result->jumpCloneImplants as $jump_clone_implant) { CharacterSheetJumpCloneImplants::create(['characterID' => $character->characterID, 'jumpCloneID' => $jump_clone_implant->jumpCloneID, 'typeID' => $jump_clone_implant->typeID, 'typeName' => $jump_clone_implant->typeName]); } // Foreach JumpCloneImplant } // Foreach Character return; }
/** * Return the character sheet for a character * * @param int $character_id * * @return \Seat\Eveapi\Models\Character\CharacterSheet */ public function getCharacterSheet(int $character_id) : CharacterSheet { return CharacterSheet::find($character_id); }
/** * @param \Seat\Web\Http\Validation\UpdateIntelNote $request * @param int $character_id * * @return \Illuminate\Http\RedirectResponse */ public function postUpdateNote(UpdateIntelNote $request, int $character_id) { CharacterSheet::updateNote($character_id, $request->input('note_id'), $request->input('title'), $request->input('note')); return redirect()->back()->with('success', 'Note updated!'); }
/** * Run the Update * * @return mixed|void */ public function call() { $pheal = $this->setScope('char')->getPheal(); foreach ($this->api_info->characters as $character) { $result = $pheal->CharacterSheet(['characterID' => $character->characterID]); // The full character sheet is pretty large. We have // a few things we can just update the database with // but also a whole bunch of things like clones // and skills that will need a loop to update. // Lets start with the easy stuff first ok. // Get the CharacterSheet Data $character_data = CharacterSheetModel::firstOrNew(['characterID' => $character->characterID]); // .. and update it $character_data->fill(['name' => $result->name, 'homeStationID' => $result->homeStationID, 'DoB' => $result->DoB, 'race' => $result->race, 'bloodLineID' => $result->bloodLineID, 'bloodLine' => $result->bloodLine, 'ancestryID' => $result->ancestryID, 'ancestry' => $result->ancestry, 'gender' => $result->gender, 'corporationName' => $result->corporationName, 'corporationID' => $result->corporationID, 'allianceName' => $result->allianceName, 'allianceID' => $result->allianceID, 'factionName' => $result->factionName, 'factionID' => isset($result->factionID) ? $result->factionID : 0, 'cloneTypeID' => $result->cloneTypeID, 'cloneName' => $result->cloneName, 'cloneSkillPoints' => $result->cloneSkillPoints, 'freeSkillPoints' => $result->freeSkillPoints, 'freeRespecs' => $result->freeRespecs, 'cloneJumpDate' => $result->cloneJumpDate, 'lastRespecDate' => $result->lastRespecDate, 'lastTimedRespec' => $result->lastTimedRespec, 'remoteStationDate' => $result->remoteStationDate, 'jumpActivation' => $result->jumpActivation, 'jumpFatigue' => $result->jumpFatigue, 'jumpLastUpdate' => $result->jumpLastUpdate, 'balance' => $result->balance, 'intelligence' => $result->attributes->intelligence, 'memory' => $result->attributes->memory, 'charisma' => $result->attributes->charisma, 'perception' => $result->attributes->perception, 'willpower' => $result->attributes->willpower]); $character_data->save(); // Next up, Implants. We need to clear up the ones // that we already know of as implants can change // at any given time. CharacterSheetImplants::where('characterID', $character->characterID)->delete(); // Lets loop over the implants and create them foreach ($result->implants as $implant) { CharacterSheetImplants::create(['characterID' => $character->characterID, 'typeID' => $implant->typeID, 'typeName' => $implant->typeName]); } // Foreach Implants // Next up, Jump Clones. Because we know that Clones can // change at any moment, we will have to take the ones // we know of and remove them, and then re-add what // we got from the API CharacterSheetJumpClone::where('characterID', $character->characterID)->delete(); CharacterSheetJumpCloneImplants::where('characterID', $character->characterID)->delete(); // Lets loop over the clones for the character. foreach ($result->jumpClones as $jump_clone) { CharacterSheetJumpClone::create(['characterID' => $character->characterID, 'jumpCloneID' => $jump_clone->jumpCloneID, 'typeID' => $jump_clone->typeID, 'locationID' => $jump_clone->locationID, 'cloneName' => $jump_clone->cloneName]); } // Foreach JumpClone // Lets loop over the Jump Clone Implants for the character foreach ($result->jumpCloneImplants as $jump_clone_implant) { CharacterSheetJumpCloneImplants::create(['characterID' => $character->characterID, 'jumpCloneID' => $jump_clone_implant->jumpCloneID, 'typeID' => $jump_clone_implant->typeID, 'typeName' => $jump_clone_implant->typeName]); } // Foreach JumpCloneImplant // Next up, Skills. Skills themselves never go away, but // obviously update as time goes by. So, lets update or // create them as needed foreach ($result->skills as $skill) { $skill_info = CharacterSheetSkills::firstOrNew(['characterID' => $character->characterID, 'typeID' => $skill->typeID]); $skill_info->fill(['skillpoints' => $skill->skillpoints, 'level' => $skill->level, 'published' => $skill->published]); $skill_info->save(); } // Foreach Skills // Next, Corporation Titles. Again, this is something that // can change as they are granted / revoked, so delete // the known once and repopulate CharacterSheetCorporationTitles::where('characterID', $character->characterID)->delete(); // Lets loop over the corporation titles and populate foreach ($result->corporationTitles as $title) { CharacterSheetCorporationTitles::create(['characterID' => $character->characterID, 'titleID' => $title->titleID, 'titleName' => $title->titleName]); } // Foreach Title } // Foreach Character return; }
/** * @return mixed */ public function getTotalCharacterIsk() { return CharacterSheet::sum('balance'); }
/** * Determine all channels in which an user is allowed to be * * @param SlackUser $slackUser * @param boolean $private Determine if channels should be private (group) or public (channel) * @return array */ protected function allowedChannels(SlackUser $slackUser, $private) { $channels = []; $rows = User::join('slack_channel_users', 'slack_channel_users.user_id', '=', 'users.id')->join('slack_channels', 'slack_channel_users.channel_id', '=', 'slack_channels.id')->select('channel_id')->where('users.id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->union(DB::table('role_user')->join('slack_channel_roles', 'slack_channel_roles.role_id', '=', 'role_user.role_id')->join('slack_channels', 'slack_channel_roles.channel_id', '=', 'slack_channels.id')->where('role_user.user_id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->union(ApiKey::join('account_api_key_info_characters', 'account_api_key_info_characters.keyID', '=', 'eve_api_keys.key_id')->join('slack_channel_corporations', 'slack_channel_corporations.corporation_id', '=', 'account_api_key_info_characters.corporationID')->join('slack_channels', 'slack_channel_corporations.channel_id', '=', 'slack_channels.id')->where('eve_api_keys.user_id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->union(CharacterSheet::join('slack_channel_alliances', 'slack_channel_alliances.alliance_id', '=', 'character_character_sheets.allianceID')->join('slack_channels', 'slack_channel_alliances.channel_id', '=', 'slack_channels.id')->join('account_api_key_info_characters', 'account_api_key_info_characters.characterID', '=', 'character_character_sheets.characterID')->join('eve_api_keys', 'eve_api_keys.key_id', '=', 'account_api_key_info_characters.keyID')->where('eve_api_keys.user_id', $slackUser->user_id)->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->union(SlackChannelPublic::join('slack_channels', 'slack_channel_public.channel_id', '=', 'slack_channels.id')->where('slack_channels.is_group', (int) $private)->where('slack_channels.is_general', (int) false)->select('channel_id'))->get(); foreach ($rows as $row) { $channels[] = $row->channel_id; } return $channels; }