コード例 #1
0
ファイル: Subscriber.php プロジェクト: janusnic/OctoberCMS
 public function onAddSubscriber()
 {
     $data = ["email" => post('email'), "latitude" => post('latitude'), "longitude" => post('longitude'), "code" => Str::random(20)];
     try {
         $subscriber = Subs::create($data);
         $data['url'] = URL::to($this->property('urlToUnsubscribe') . "/" . $data['code']);
         \Mail::send('jorgeandrade.subscribe::mail.subscribe', $data, function ($message) use($data) {
             $message->to($data['email'], 'Hi New Subscriber');
         });
         $this->page['result'] = $this->property('thanksMessage');
     } catch (\Exception $e) {
         $this->page['result'] = $this->property('errorMessage');
     }
 }
コード例 #2
0
ファイル: Profile.php プロジェクト: Smony/njphoto
 public function onRemoveSubscriber()
 {
     $email = post('email');
     $code = post('code');
     try {
         $subscriber = Subs::whereCode($code)->whereEmail($email)->whereStatus(1)->firstOrFail();
         $subscriber->status = 0;
         $subscriber->code = null;
         $subscriber->save();
         \Mail::send('jorgeandrade.subscribe::mail.unsubscribe', [], function ($message) use($email) {
             $message->to($email, 'Bye old Subscriber');
         });
         $this->page['result'] = $this->property('thanksMessage');
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         $this->page['result'] = "Email not found!";
     } catch (\Exception $e) {
         $this->page['result'] = $this->property('errorMessage');
     }
 }