contact = $contact; } /** * Execute the job. * * @return void */ public function handle() { $account = $this->contact->account; $users = []; foreach ($account->users as $user) { if ($user->isTheRightTimeToBeReminded($this->contact->stay_in_touch_trigger_date) && ! AccountHelper::hasLimitations($account)) { array_push($users, $user); } } if (count($users) > 0) { NotificationFacade::send($users, new StayInTouchEmail($this->contact)); $this->contact->setStayInTouchTriggerDate($this->contact->stay_in_touch_frequency, $this->contact->stay_in_touch_trigger_date); return; } $now = now(); while ($this->contact->stay_in_touch_trigger_date < $now) { // If stay in touch was missed, we reschedule it. $this->contact->setStayInTouchTriggerDate($this->contact->stay_in_touch_frequency, $this->contact->stay_in_touch_trigger_date); } } }