Beispiel #1
0
 /**
  * Run the Update
  *
  * @return mixed
  */
 public function call()
 {
     $pheal = $this->setScope('corp')->setCorporationID()->getPheal();
     $result = $pheal->Bookmarks();
     // Process each folder and the bookmarks therein
     foreach ($result->folders as $folder) {
         // Currently a denormalized table is used for both
         // the folder information as well as the bookmarks
         // themselves.
         foreach ($folder->bookmarks as $bookmark) {
             $location_info = $this->find_nearest_celestial($bookmark->locationID, $bookmark->x, $bookmark->y, $bookmark->z);
             $bookmark_info = Bookmark::firstOrNew(['corporationID' => $this->corporationID, 'folderID' => $folder->folderID, 'bookmarkID' => $bookmark->bookmarkID]);
             $bookmark_info->fill(['folderName' => $folder->folderName, 'creatorID' => $bookmark->creatorID, 'created' => $bookmark->created, 'itemID' => $bookmark->itemID, 'typeID' => $bookmark->typeID, 'locationID' => $bookmark->locationID, 'x' => $bookmark->x, 'y' => $bookmark->y, 'z' => $bookmark->z, 'mapID' => $location_info['mapID'], 'mapName' => $location_info['mapName'], 'memo' => $bookmark->memo, 'note' => $bookmark->note]);
             $bookmark_info->save();
         }
         // Foreach Bookmark
         // Cleanup old bookmarks in this folder
         Bookmark::where('corporationID', $this->corporationID)->where('folderID', $folder->folderID)->whereNotIn('bookmarkID', array_map(function ($bookmark) {
             return $bookmark->bookmarkID;
         }, (array) $folder->bookmarks))->delete();
     }
     // Foreach Folder
     // Cleanup old folders
     Bookmark::where('corporationID', $this->corporationID)->whereNotIn('folderID', array_map(function ($folder) {
         return $folder->folderID;
     }, (array) $result->folders))->delete();
     return;
 }
Beispiel #2
0
 /**
  * Get a corporations Bookmarks
  *
  * @param int $corporation_id
  *
  * @return \Illuminate\Support\Collection
  */
 public function getCorporationBookmarks(int $corporation_id) : Collection
 {
     return Bookmark::where('corporationID', $corporation_id)->get();
 }
 /**
  * Get a corporations Bookmarks
  *
  * @param $corporation_id
  *
  * @return mixed
  */
 public function getCorporationBookmarks($corporation_id)
 {
     return Bookmark::where('corporationID', $corporation_id)->get();
 }