/** * 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; }
/** * Return the contact labels for a Corporation * * @param $corporation_id * * @return mixed */ public function getCorporationContactsLabels($corporation_id) { return ContactListLabel::where('corporationID', $corporation_id)->get(); }