Exemplo n.º 1
0
 public function copyFrom(Contact $contact, $userId)
 {
     $replicatedContact = $contact->replicate(['id']);
     $replicatedContact->user()->associate($userId);
     $replicatedContact->businesses()->detach();
     $replicatedContact->save();
     $this->business->contacts()->attach($replicatedContact);
     $this->business->save();
     return $replicatedContact;
 }
Exemplo n.º 2
0
 protected function linkContactToUser(Contact $contact)
 {
     if ($contact->email === null) {
         return $this;
     }
     $user = User::where(['email' => $contact->email])->first();
     if ($user === null) {
         $contact->user()->dissociate();
         $contact->save();
         return $this;
     }
     $contact->user()->associate($user);
     $contact->save();
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Detach a Contact froma Business addressbok.
  *
  * @param Business $business
  * @param Contact  $contact
  *
  * @return int
  */
 public function detach(Business $business, Contact $contact)
 {
     return $contact->businesses()->detach($business->id);
 }