/** * Display a listing of destinos * * @return Response */ public function postIndex() { if (Input::has('email') && Input::get('email')) { $check = Mailing::where('email', '=', Input::get('email'))->first(); if (!$check) { $mailing = new Mailing(); $mailing->email = Input::get('email'); $mailing->nome = Input::get('nome'); $mailing->phone = Input::get('phone'); $mailing->save(); return Redirect::back()->with('success', array('Você foi registrado no Mailing.')); } else { return Redirect::back()->with('danger', array('Você ja esta registrado no mailing.')); } } else { return Redirect::back()->with('danger', array('Seu email esta incorreto.')); } }
public function fire($job, $data) { $file = Config::get('projeter.upload_path') . $data['file']; Log::info("Starting to add {$data['target']} to database (File: {$file})"); $target = new Target(); $target->name = $data['target']; $target->save(); $reader = new \EasyCSV\Reader($file); // There must be a Email field in CSV file /*if(!in_array('Email', $reader->getHeaders() )) throw new Exception("Email field not found", 1);*/ while ($row = $reader->getRow()) { Log::info("Adding {$row['Email']} to the target {$data['target']}"); $mailing = new Mailing(); $mailing->target()->associate($target); $mailing->email = $row['Email']; $mailing->save(); } Log::info("Mailing list {$target->name} added to database"); $job->delete(); }
/** * Store a newly created mailing in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Mailing::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $mailing = new Mailing(); $mailing->nome_br = $data['nome_br']; $mailing->nome_en = $data['nome_en']; $mailing->descricao_br = $data['descricao_br']; $mailing->descricao_en = $data['descricao_en']; $mailing->pais_id = $data['pais_id']; //$mailing->estado = $data['estado']; $mailing->publicado = $data['publicado']; if (Input::hasFile('imagem')) { $up_success = $this->uploadImage(Input::file('imagem'), 'mailings'); if ($up_success) { $mailing->imagem = $up_success['filename']; } } $mailing->save(); if (Input::hasFile('imagens')) { $imagens = Input::file('imagens'); foreach ($imagens as $img) { $imginfo = $this->uploadImage($img, 'mailings'); if ($imginfo) { $imagem = new Imagem(); $imagem->nome = $imginfo['filename']; $imagem->caminho = $imginfo['destinationPath']; $mailing->imagens()->save($imagem); } } } return Redirect::to('admin/mailing/')->with('success', array('Registro salvo.')); }