fetchminingtaxesobservers

This commit is contained in:
2021-05-18 18:28:36 +09:00
parent d815c15176
commit 1c4406a6eb

View File

@@ -88,36 +88,34 @@ class FetchMiningTaxesObservers implements ShouldQueue
//Run through the mining observers, and add them to the database //Run through the mining observers, and add them to the database
foreach($resp as $observer) { foreach($resp as $observer) {
if($observer->observer_id > 1030000000000) { //See if the observer is found in the database
//See if the observer is found in the database $found = Observer::where([
$found = Observer::where([ 'observer_id' => $observer->observer_id,
])->count();
//Get the observer name from esi
$structureInfo = $sHelper->GetStructureInfo($observer->observer_id);
//If found, then update the structure
if($found > 0) {
//Update the existing structure in the database
Observer::where([
'observer_id' => $observer->observer_id, 'observer_id' => $observer->observer_id,
])->count(); ])->update([
'observer_id' => $observer->observer_id,
//Get the observer name from esi 'observer_name' => $structureInfo->name,
$structureInfo = $sHelper->GetStructureInfo($observer->observer_id); 'last_updated' => $observer->last_updated,
]);
//If found, then update the structure } else {
if($found > 0) { //Add a new observer into the observer table
//Update the existing structure in the database $newObs = new Observer;
Observer::where([ $newObs->observer_id = $observer->observer_id;
'observer_id' => $observer->observer_id, $newObs->observer_type = $observer->observer_type;
])->update([ $newObs->observer_name = $structureInfo->name;
'observer_id' => $observer->observer_id, $newObs->last_updated = $observer->last_updated;
'observer_name' => $structureInfo->name, $newObs->solar_system_id = $structureInfo->solar_system_id;
'last_updated' => $observer->last_updated, $newObs->solar_system_name = $lookup->SystemIdToName($structureInfo->solar_system_id);
]); $newObs->save();
} else {
//Add a new observer into the observer table
$newObs = new Observer;
$newObs->observer_id = $observer->observer_id;
$newObs->observer_type = $observer->observer_type;
$newObs->observer_name = $structureInfo->name;
$newObs->last_updated = $observer->last_updated;
$newObs->solar_system_id = $structureInfo->solar_system_id;
$newObs->solar_system_name = $lookup->SystemIdToName($structureInfo->solar_system_id);
$newObs->save();
}
} }
} }