Skip to content

Instantly share code, notes, and snippets.

@eminetto
Created August 20, 2014 13:58
Show Gist options
  • Save eminetto/7551a7d210778e48d8d4 to your computer and use it in GitHub Desktop.
Save eminetto/7551a7d210778e48d8d4 to your computer and use it in GitHub Desktop.
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