/**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent $event
  *
  * @return void
  */
 public function handle(MaintenanceWasScheduledEvent $event)
 {
     if (!$event->incident->notify) {
         return false;
     }
     $data = AutoPresenter::decorate($event->incident);
     foreach ($this->subscriber->verified()->get() as $subscriber) {
         $mail = ['email' => $subscriber->email, 'subject' => 'Scheduled maintenance.', 'status' => $data->humanStatus, 'html_content' => $data->formattedMessage, 'text_content' => $data->message, 'scheduled_at' => $data->scheduled_at_formatted, 'token' => $subscriber->token, 'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code])];
         $this->mailer->queue(['html' => 'emails.incidents.maintenance-html', 'text' => 'emails.incidents.maintenance-text'], $mail, function (Message $message) use($mail) {
             $message->to($mail['email'])->subject($mail['subject']);
         });
     }
 }
 /**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Events\Incident\IncidentHasReportedEvent $event
  *
  * @return void
  */
 public function handle(IncidentWasReportedEvent $event)
 {
     if (!$event->incident->notify) {
         return false;
     }
     $incident = AutoPresenter::decorate($event->incident);
     $component = AutoPresenter::decorate($event->incident->component);
     // Only send emails for public incidents.
     if ($event->incident->visible === 1) {
         foreach ($this->subscriber->verified()->get() as $subscriber) {
             $mail = ['email' => $subscriber->email, 'subject' => 'New incident reported.', 'has_component' => $event->incident->component ? true : false, 'component_name' => $component ? $component->name : null, 'status' => $incident->humanStatus, 'html_content' => $incident->formattedMessage, 'text_content' => $incident->message, 'token' => $subscriber->token, 'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code])];
             $this->mailer->queue(['html' => 'emails.incidents.new-html', 'text' => 'emails.incidents.new-text'], $mail, function (Message $message) use($mail) {
                 $message->to($mail['email'])->subject($mail['subject']);
             });
         }
     }
 }