Created
August 20, 2014 13:58
-
-
Save eminetto/7551a7d210778e48d8d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function contato() { | |
return View::make('pages.contato'); | |
} | |
public function postContato() { | |
$rules = array( 'nome' => 'required', 'email' => 'required|email', 'texto' => 'required' ); | |
$validation = Validator::make(Input::all(), $rules); | |
$data = array(); | |
$data['nome'] = Input::get("nome"); | |
$data['email'] = Input::get("email"); | |
$data['texto'] = Input::get("texto"); | |
if($validation->passes()) { | |
Mail::send('emails.contato', $data, function($message) { | |
$message->from(Input::get('email'), Input::get('nome')); | |
$message->to('contato@billjr.com.br') ->subject('Contato Bill Jr.'); | |
}); | |
return Redirect::to('contato') ->with('message', 'Mensagem enviada com sucesso!'); | |
} | |
return Redirect::to('contato') | |
->withInput() | |
->withErrors($validation) | |
->with('message', 'Erro! Preencha todos os campos corretamente.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment