/** * 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; }
/** * Return the skills detail for a specific Character * * @param $character_id * * @return mixed */ public function getCharacterSkillsInformation($character_id) { return CharacterSheetSkills::join('invTypes', 'character_character_sheet_skills.typeID', '=', 'invTypes.typeID')->join('invGroups', 'invTypes.groupID', '=', 'invGroups.groupID')->where('character_character_sheet_skills.characterID', $character_id)->orderBy('invTypes.typeName')->get(); }
/** * 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 doSearchCharacterSkills() { // Get the user $user = auth()->user(); // Start the skills query $skills = CharacterSheetSkills::join('invTypes', 'character_character_sheet_skills.typeID', '=', 'invTypes.typeID')->join('invGroups', 'invTypes.groupID', '=', 'invGroups.groupID')->join('account_api_key_info_characters', 'character_character_sheet_skills.characterID', '=', 'account_api_key_info_characters.characterID')->join('eve_api_keys', 'eve_api_keys.key_id', '=', 'account_api_key_info_characters.keyID'); // If the user is not a superuser, filter the results. if (!$user->hasSuperUser()) { $skills = $skills->where(function ($query) use($user) { // If the user has any affiliations and can // list those characters, add them if ($user->has('character.skills', false)) { $query = $query->whereIn('account_api_key_info_characters.characterID', array_keys($user->getAffiliationMap()['char'])); } // Add any characters from owner API keys $query->orWhere('eve_api_keys.user_id', $user->id); }); } return $skills; }
/** * @return mixed */ public function getTotalCharacterSkillpoints() { return CharacterSheetSkills::sum('skillpoints'); }
/** * Get the numer of skills per Level for a character. * * @param int $character_id * * @return array */ public function getCharacterSkillsAmountPerLevel(int $character_id) : array { $skills = CharacterSheetSkills::where('characterID', $character_id)->get(); return [$skills->where('level', 0)->count(), $skills->where('level', 1)->count(), $skills->where('level', 2)->count(), $skills->where('level', 3)->count(), $skills->where('level', 4)->count(), $skills->where('level', 5)->count()]; }