示例#1
0
 protected function handleUnsubscribe()
 {
     if (!isset($this->subscriber->pivot)) {
         return 'You are already unsubscribed from our mailing list!';
     }
     $pivot = $this->subscriber->pivot;
     if ($pivot->stop_at) {
         return 'You are already unsubscribed from our mailing list!';
     }
     $pivot->stop_at = $this->campaign->freshTimestamp();
     $pivot->read_at = $this->campaign->freshTimestamp();
     $pivot->save();
     $this->campaign->count_read++;
     $this->campaign->count_stop++;
     $this->campaign->save();
     $this->subscriber->confirmed_at = null;
     $this->subscriber->unsubscribed_at = $this->subscriber->freshTimestamp();
     $this->subscriber->save();
     // @todo Template + Language
     return '<html><head><title>Unsubscribe successful</title></head><body><h1>Unsubscribe successful</h1><p>Your email has been successfully unsubscribed from this list!</p></body></html>';
 }