Пример #1
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $pheal = $this->setScope('corp')->setCorporationID()->getPheal();
     // Looking at the AssetsList update, we see that
     // the table is cleaned up beforehand as the
     // itemID's may change for assets. For this call
     // to the Locations endpoint, we will also have
     // to cleanup as we will be referencing the same
     // itemID's
     LocationsModel::where('corporationID', $this->corporationID)->delete();
     // We get an array of items ID's that is keyed
     // by the itemID's so that we can later use this
     // same array to lookup the locationID for the
     // nearest_celestial lookup.
     $item_ids = AssetListModel::where('corporationID', $this->corporationID)->get()->keyBy('itemID')->toArray();
     // Chunk the requests to the API as the ids field
     // could get too long with all of the bigInts inside
     // of the query string.
     foreach (array_chunk($item_ids, 100) as $items) {
         // Apply array_column so that we only pass the
         // itemID's in the query string to the API
         $result = $pheal->Locations(['ids' => implode(',', array_column($items, 'itemID'))]);
         foreach ($result->locations as $location) {
             $nearest_celestial = $this->find_nearest_celestial($item_ids[$location->itemID]['locationID'], $location->x, $location->y, $location->z);
             LocationsModel::create(['corporationID' => $this->corporationID, 'itemID' => $location->itemID, 'itemName' => $location->itemName, 'x' => $location->x, 'y' => $location->y, 'z' => $location->z, 'mapID' => $nearest_celestial['mapID'], 'mapName' => $nearest_celestial['mapName']]);
         }
         // Foreach Location
     }
     return;
 }
Пример #2
0
 /**
  * Returns a corporation assets grouped by location.
  * Only assets in space will appear here as assets
  * that are in stations dont have 'locations' entries.
  *
  * @param $corporation_id
  *
  * @return mixed
  */
 public function getCorporationAssetByLocation($corporation_id)
 {
     return Locations::leftJoin('corporation_asset_lists', 'corporation_locations.itemID', '=', 'corporation_asset_lists.itemID')->leftJoin('invTypes', 'corporation_asset_lists.typeID', '=', 'invTypes.typeID')->where('corporation_locations.corporationID', $corporation_id)->get()->groupBy('mapID');
     // <--- :O That is so sexy <3
 }