Beispiel #1
0
 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');
     }
 }
Beispiel #2
0
 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');
     }
 }