Пример #1
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $pheal = $this->setScope('char')->getPheal();
     foreach ($this->api_info->characters as $character) {
         $result = $pheal->PlanetaryColonies(['characterID' => $character->characterID]);
         // Update the Planetary Colonies for the character.
         // As this can obiously change a lot, we will have
         // to clean up the ones that we did not receive in
         // this update call.
         foreach ($result->colonies as $colony) {
             $colony_info = PlanetaryColony::firstOrNew(['ownerID' => $colony->ownerID, 'planetID' => $colony->planetID]);
             $colony_info->fill(['solarSystemID' => $colony->solarSystemID, 'solarSystemName' => $colony->solarSystemName, 'planetName' => $colony->planetName, 'planetTypeID' => $colony->planetTypeID, 'planetTypeName' => $colony->planetTypeName, 'ownerID' => $colony->ownerID, 'ownerName' => $colony->ownerName, 'lastUpdate' => $colony->lastUpdate, 'upgradeLevel' => $colony->upgradeLevel, 'numberOfPins' => $colony->numberOfPins]);
             $colony_info->save();
         }
         // Foreach colony
         // Cleanup the Colonies that are not in the reponse.
         PlanetaryColony::where('ownerID', $character->characterID)->whereNotIn('planetID', array_map(function ($colony) {
             return $colony->planetID;
         }, (array) $result->colonies))->delete();
     }
     return;
 }
Пример #2
0
 /**
  * Return the Planetary Colonies for a character
  *
  * @param $character_id
  *
  * @return mixed
  */
 public function getCharacterPlanetaryColonies($character_id)
 {
     return PlanetaryColony::where('ownerID', $character_id)->get();
 }