modified the way characters are looked up in the database versus esi
This commit is contained in:
@@ -231,7 +231,7 @@ class ContractController extends Controller
|
|||||||
$characterId = auth()->user()->getId();
|
$characterId = auth()->user()->getId();
|
||||||
$characterName = auth()->user()->getName();
|
$characterName = auth()->user()->getName();
|
||||||
//Use the lookup helper in order to find the user's corporation id and name
|
//Use the lookup helper in order to find the user's corporation id and name
|
||||||
$char = $looup->LookupCharacter($characterId, null);
|
$char = $lookup->GetCharacterInfo($characterId);
|
||||||
$corporationId = $char->corporation_id;
|
$corporationId = $char->corporation_id;
|
||||||
//use the lookup helper in order to find the corporation's name from it's id.
|
//use the lookup helper in order to find the corporation's name from it's id.
|
||||||
$corp = $lookup->LookupCorporation($corporationId, null);
|
$corp = $lookup->LookupCorporation($corporationId, null);
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class MoonsAdminController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Let's find the corporation and alliance information to ascertain whethery they are in Warped Intentions or another Legacy Alliance
|
//Let's find the corporation and alliance information to ascertain whethery they are in Warped Intentions or another Legacy Alliance
|
||||||
$char = $lookup->LookupCharacter($contact, null);
|
$char = $lookup->GetCharacterInfo($contact);
|
||||||
$corp = $lookup->LookupCorporation($char->character_id, null);
|
$corp = $lookup->LookupCorporation($char->character_id, null);
|
||||||
$allianceId = $corp->alliance_id;
|
$allianceId = $corp->alliance_id;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class WikiController extends Controller
|
|||||||
$charId = $charIdTemp[0]->character_id;
|
$charId = $charIdTemp[0]->character_id;
|
||||||
|
|
||||||
//Set the corp id
|
//Set the corp id
|
||||||
$char = $lookup->LookupCharacter($charId, null);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
$corpId = $char->corporation_id;
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Set the alliance id
|
//Set the alliance id
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ class FinanceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Reference to see if the character is in our look up table for corporations and characters
|
//Reference to see if the character is in our look up table for corporations and characters
|
||||||
$corpId = $lookup->LookupCharacter($charId, null);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Create an ESI authentication container
|
//Create an ESI authentication container
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
@@ -136,7 +137,8 @@ class FinanceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Refrence to see if the character is in our look up table for corporation and characters
|
//Refrence to see if the character is in our look up table for corporation and characters
|
||||||
$corpId = $lookup->LookupCharacter($charId, null);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Create the ESI authentication container
|
//Create the ESI authentication container
|
||||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||||
@@ -221,7 +223,8 @@ class FinanceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Reference to see if the character is in our look up table for corporations and characters
|
//Reference to see if the character is in our look up table for corporations and characters
|
||||||
$char = $lookup->LookupCharacter($charId, null);
|
$char = $lookup->GetCharacterInfo($charId);
|
||||||
|
|
||||||
$corpId = $char->corporation_id;
|
$corpId = $char->corporation_id;
|
||||||
|
|
||||||
//Create an ESI authentication container
|
//Create an ESI authentication container
|
||||||
|
|||||||
@@ -147,15 +147,67 @@ class LookupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function GetCharacterInfo($charId) {
|
public function GetCharacterInfo($charId) {
|
||||||
try {
|
//Check our own database first
|
||||||
$character = $this->esi->invoke('get', '/characters/{character_id}/', [
|
$char = $this->LookupCharacter($charId, null);
|
||||||
'character_id' => $charId,
|
|
||||||
]);
|
|
||||||
} catch(RequestFailedException $e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $character;
|
//if the character was not found in the database, then get the information and store it in our database for later
|
||||||
|
if($char == null) {
|
||||||
|
try {
|
||||||
|
$character = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||||
|
'character_id' => $charId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get character information in GetCharacterInfo in Lookup');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Store the character in our database
|
||||||
|
$this->SaveCharacter($character, $charId);
|
||||||
|
|
||||||
|
//Return the character details to the calling function
|
||||||
|
return $character;
|
||||||
|
} else {
|
||||||
|
//Return what was pulled from the database
|
||||||
|
return $char;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetCorporationInfo($corpId) {
|
||||||
|
//Check our own database first
|
||||||
|
$corp = $this->LookupCorporation($corpId, null);
|
||||||
|
|
||||||
|
//If the corporation was not found in the database, then get the information and store it in our database for later
|
||||||
|
if($corp == null) {
|
||||||
|
try {
|
||||||
|
$corporation = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||||
|
'corporation_id' => $corpId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get corporation information in GetCorporationInfo in Lookup');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Return what was pulled from the database
|
||||||
|
return $corp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetAllianceInfo($allianceId) {
|
||||||
|
//Check our own database first
|
||||||
|
$ally = $this->LookupAlliance($corpId, null);
|
||||||
|
|
||||||
|
if($ally == null) {
|
||||||
|
try {
|
||||||
|
$alliance = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||||
|
'alliance_id' => $allianceId,
|
||||||
|
]);
|
||||||
|
} catch(RequestFailedException $e) {
|
||||||
|
Log::warning('Failed to get alliance information in GetAllianceInfo in Lookup');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $ally;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CharacterIdToName($charId) {
|
public function CharacterIdToName($charId) {
|
||||||
@@ -321,7 +373,7 @@ class LookupHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LookupCharacter($id = null, $name = null) {
|
private function LookupCharacter($id = null, $name = null) {
|
||||||
//If both the id and name are null, then there is nothing to lookup
|
//If both the id and name are null, then there is nothing to lookup
|
||||||
if($id == null & $name == null) {
|
if($id == null & $name == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -351,7 +403,7 @@ class LookupHelper {
|
|||||||
return $character;
|
return $character;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LookupCorporation($id = null, $name = null) {
|
private function LookupCorporation($id = null, $name = null) {
|
||||||
if($id == null && $name == null) {
|
if($id == null && $name == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -378,7 +430,7 @@ class LookupHelper {
|
|||||||
return $corporation;
|
return $corporation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function LookupAlliance($id = null, $name = null) {
|
private function LookupAlliance($id = null, $name = null) {
|
||||||
if($id == null && $name == null) {
|
if($id == null && $name == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user