Exemplo n.º 1
0
 /**
  * Execute the console command.
  */
 public function handle()
 {
     $newsletterlist = EmailList::findOrFail(config('proto.weeklynewsletter'));
     $events = Event::getEventsForNewsletter();
     if ($events->count() > 0) {
         $this->info('Sending weekly newsletter to ' . $newsletterlist->users->count() . ' people.');
         foreach ($newsletterlist->users as $user) {
             $email = $user->email;
             $name = $user->name;
             Mail::queue('emails.newsletter', ['user' => $user, 'list' => $newsletterlist], function ($message) use($email, $name) {
                 $message->to($email, $name)->from('internal@' . config('proto.emaildomain'), config('proto.internal'))->subject('S.A. Proto Weekly Newsletter (Week ' . date("W") . ')');
             });
         }
         $this->info("Done!");
     } else {
         $this->info("There are no upcomming activities.");
     }
 }
Exemplo n.º 2
0
 public function unsubscribeLink(Request $request, $hash)
 {
     $data = EmailList::parseUnsubscribeHash($hash);
     $user = User::findOrFail($data->user);
     $list = EmailList::findOrFail($data->list);
     $sub = EmailListSubscription::where('user_id', $user->id)->where('list_id', $list->id)->first();
     if ($sub != null) {
         $request->session()->flash('flash_message', $user->name . ' has been unsubscribed from ' . $list->name);
         $sub->delete();
     } else {
         $request->session()->flash('flash_message', $user->name . ' was already unsubscribed from ' . $list->name);
     }
     return Redirect::route('homepage');
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy(Request $request, $id)
 {
     $list = EmailList::findOrFail($id);
     $list->delete();
     $request->session()->flash('flash_message', 'The list has been deleted!');
     return Redirect::route('email::admin');
 }