moons admin controller
This commit is contained in:
@@ -83,6 +83,49 @@ class LookupHelper {
|
||||
}
|
||||
}
|
||||
|
||||
//Add corporations to the lookup table for quicker lookups without having to
|
||||
//hit the ESI API all the time
|
||||
public function LookupCorporation($corpId) {
|
||||
//Check for the character in the user_to_corporation table
|
||||
$found = CorporationToAlliance::where('corporation_id', $charId)->get(['alliance_id']);
|
||||
|
||||
//If we don't find the character in the table, then we retrieve from ESI
|
||||
//and add the character to the table
|
||||
if(!isset($found[0]->alliance_id)) {
|
||||
//Get the configuration for ESI from the environmental variables
|
||||
$config = config('esi');
|
||||
|
||||
//Setup a new ESI container
|
||||
$esi = new Eseye();
|
||||
|
||||
//Try to get the character information, then the corporation information
|
||||
try {
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
$alliance = $esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $corporation->alliance_id,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e){
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
|
||||
//Save all of the data to the database
|
||||
$corp = new CorporationToAlliance;
|
||||
$corp->corporation_id = $corporation->corporation_id;
|
||||
$corp->corporation_name = $corporation->name;
|
||||
$corp->alliance_id = $corporation->alliance_id;
|
||||
$corp->alliance_name = $alliance->name;
|
||||
$corp->save();
|
||||
|
||||
//Return the corporation_id which is what the calling function is looking for
|
||||
return $corporation->alliance_id;
|
||||
} else {
|
||||
//Return the corporation_id if it was found in the database as it is what the calling function is looking for
|
||||
return $found[0]->alliance_id;
|
||||
}
|
||||
}
|
||||
|
||||
//Update the character lookup table as often as necessary
|
||||
public function UpdateLookupCharacter() {
|
||||
//Create a new ESI container
|
||||
@@ -118,48 +161,6 @@ class LookupHelper {
|
||||
}
|
||||
}
|
||||
|
||||
//Add corporations to the lookup table for quicker lookups without having to
|
||||
//hit the ESI API all the time
|
||||
public function LookupCorporation($corpId) {
|
||||
//Check for the character in the user_to_corporation table
|
||||
$found = CorporationToAlliance::where('corporation_id', $charId)->get(['alliance_id']);
|
||||
|
||||
//If we don't find the character in the table, then we retrieve from ESI
|
||||
//and add the character to the table
|
||||
if(!isset($found[0]->alliance_id)) {
|
||||
//Get the configuration for ESI from the environmental variables
|
||||
$config = config('esi');
|
||||
|
||||
//Setup a new ESI container
|
||||
$esi = new Eseye();
|
||||
|
||||
//Try to get the character information, then the corporation information
|
||||
try {
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
$alliance = $esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $corporation->alliance_id,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e){
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
|
||||
//Save all of the data to the database
|
||||
$char = new UserToCorporation;
|
||||
$char->character_id = $corpId;
|
||||
$char->character_name = $corporation->name;
|
||||
$char->corporation_id = $corporation->corporation_id;
|
||||
$char->corporation_name = $corporation->name;
|
||||
$char->save();
|
||||
//Return the corporation_id which is what the calling function is looking for
|
||||
return $corporation->alliance_id;
|
||||
} else {
|
||||
//Return the corporation_id if it was found in the database as it is what the calling function is looking for
|
||||
return $found[0]->alliance_id;
|
||||
}
|
||||
}
|
||||
|
||||
//Update the corporation lookup table as often as necessary
|
||||
public function UpdateLookupCorporation() {
|
||||
//Create a new ESI container
|
||||
|
||||
Reference in New Issue
Block a user