Ejemplo n.º 1
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $pheal = $this->setScope('corp')->setCorporationID()->getPheal();
     $result = $pheal->ContactList();
     // Contact Lists can change just like many other
     // types of information. So, we have to delete
     // the current list and recreate it with the
     // new data we sourced from the API.
     ContactListModel::where('corporationID', $this->corporationID)->delete();
     foreach ($result->corporateContactList as $contact) {
         ContactListModel::create(['corporationID' => $this->corporationID, 'contactID' => $contact->contactID, 'contactName' => $contact->contactName, 'standing' => $contact->standing, 'contactTypeID' => $contact->contactTypeID, 'labelMask' => $contact->labelMask]);
     }
     // Corporation Contacts also have Labels.
     ContactListLabel::where('corporationID', $this->corporationID)->delete();
     foreach ($result->corporateContactLabels as $label) {
         ContactListLabel::create(['corporationID' => $this->corporationID, 'labelID' => $label->labelID, 'name' => $label->name]);
     }
     // Next up, Alliance Contacts. Exactly the same applies
     // to these as the above corporate contacts
     ContactListAlliance::where('corporationID', $this->corporationID)->delete();
     foreach ($result->allianceContactList as $contact) {
         ContactListAlliance::create(['corporationID' => $this->corporationID, 'contactID' => $contact->contactID, 'contactName' => $contact->contactName, 'standing' => $contact->standing, 'contactTypeID' => $contact->contactTypeID, 'labelMask' => $contact->labelMask]);
     }
     // And now, the labels for the Alliance Contact List
     ContactListAllianceLabel::where('corporationID', $this->corporationID)->delete();
     foreach ($result->allianceContactLabels as $label) {
         ContactListAllianceLabel::create(['corporationID' => $this->corporationID, 'labelID' => $label->labelID, 'name' => $label->name]);
     }
     return;
 }
Ejemplo n.º 2
0
 /**
  * Return the contacts list for a corporation
  *
  * @param $corporation_id
  *
  * @return mixed
  */
 public function getCorporationContacts($corporation_id)
 {
     return ContactList::where('corporationID', $corporation_id)->orderBy('standing', 'desc')->get();
 }
Ejemplo n.º 3
0
 /**
  * Return the contacts list for a corporation
  *
  * @param int $corporation_id
  *
  * @return \Illuminate\Support\Collection
  */
 public function getCorporationContacts(int $corporation_id) : Collection
 {
     return ContactList::where('corporationID', $corporation_id)->join('invTypes', function ($join) {
         $join->on('invTypes.typeID', '=', 'corporation_contact_lists.contactTypeID');
     })->orderBy('standing', 'desc')->get();
 }