Exemplo n.º 1
0
 private function fireNastySpam(ListMailing $listMailing)
 {
     $listMailing->listMembers()->where('status', 'pending')->get()->each(function (ListMember $listMember) {
         !($sender = $this->getSender()) && dd('no sender');
         $sender->send(new SpamMessage($listMember, $this->mailing));
         $listMember->status = 'done';
         $listMember->save();
     });
     $listMailing->status = 'finish';
     $listMailing->save();
     $this->mailing->status = 'finish';
     $this->mailing->save();
 }
Exemplo n.º 2
0
 public function PostCreateMailing()
 {
     //TODO:refactorizar los parametros del filtro con los del post
     $cuenta = Input::get('cuenta');
     $estado = Input::get('estado');
     $programa = Input::get('programa');
     $titulo = Input::get('titulo');
     $texto = Input::get('texto');
     $users = array();
     if ($cuenta == '0') {
         $query_users = User::with('plan');
     } else {
         if ($cuenta == 'activas') {
             $query_users = User::where('cuenta_activa', true);
         } else {
             $query_users = User::where('cuenta_activa', false);
         }
     }
     if ($estado != '0') {
         $query_users = $query_users->where('estado', $estado);
     }
     $users = $query_users->get();
     $mailing = new Mailing();
     $mailing->user_id = \Auth::user()->id;
     $mailing->titulo = $titulo;
     $mailing->texto = $texto;
     $mailing->enviado = true;
     $mailing->save();
     foreach ($users as $user) {
         $email = $user->email;
         $fullname = $user->name . ' ' . $user->last_name;
         $data = array('fullname' => $fullname, 'titulo' => $titulo, 'texto' => $texto);
         try {
             \Mail::send('emails.anuncio', $data, function ($message) use($email, $titulo) {
                 $message->from('*****@*****.**', 'BoxMagic');
                 $message->to($email)->subject($titulo);
             });
         } catch (\Exception $e) {
             //enviarme un correo con la exception
         }
         \DB::table('usuarios_mailing')->insert(['user_id' => $user->id, 'mailing_id' => $mailing->id]);
     }
     \Session::flash('message', 'Correos enviado con exito!');
     \Session::flash('alert-class', 'alert-success');
     return redirect('mailing/lista');
 }
Exemplo n.º 3
0
 public function getCheck()
 {
     DB::enableQueryLog();
     $st = Mailing::first()->createdBy()->whereBetween('created_at', [date('Y-m-d H:00:00'), date('Y-m-d H:59:59')])->count();
     return DB::getQueryLog();
 }