Created
October 15, 2014 00:06
-
-
Save juniorb2ss/c8056a30b5d2dbb56dbc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 postAtendimentos() | |
| { | |
| // Regras de validação do formulário | |
| $validator = \Validator::make(\Input::all(), | |
| array( | |
| 'assunto' => 'required|min:5', | |
| 'cliente' => 'required|min:1', | |
| 'categoria' => 'required|min:1', | |
| 'descricao' => 'required|min:20', | |
| 'status' => 'required|min:5' | |
| ) | |
| ); | |
| // Validação ok? Não, retorna o formulário para o usuário e os erros, junto com os inputs | |
| if ($validator->fails()) | |
| { | |
| return \Redirect::route('admin.home')->withErrors($validator->messages())->withInput(); | |
| } | |
| // Validação ok? Sim, prepara a inserção da informação | |
| $suporte = new Suportes; | |
| $suporte->user_id = \Sentry::getUser()->id; | |
| $suporte->assunto = \Input::get('assunto'); | |
| $suporte->cliente_id = \Input::get('cliente'); | |
| $suporte->categoria_id = \Input::get('categoria'); | |
| $suporte->descricao = \Input::get('descricao'); | |
| $suporte->status = \Input::get('status'); | |
| // Salva o formulário | |
| if($suporte->save()) | |
| { | |
| // Dispara email utilizando um template | |
| \Mail::send('email.suporte', [ 'suporte' => $suporte ], function($message) { | |
| $message->to('juniorb2ss@gmail.com', 'Penasoft Suporte')->subject('Notificação de Suporte'); | |
| }); | |
| // Redireciona o usuário junto com a mensagem. | |
| return \Redirect::route('admin.home')->with('MessageAtendimentoBox', 'Suporte registrado com sucesso!'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment