SHARE
TWEET

Untitled

a guest Jun 25th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace AppHttpControllers;
  4. use IlluminateHttpRequest;
  5. use IlluminateSupportFacadesDB;
  6. use AppClientes;
  7. use Validator; // ValidaĆ§Ć£o
  8. use AppHttpRequestsClienteRules;// Regras do formulƔrio
  9.  
  10. class VendedorController extends Controller
  11. {
  12.     public function cadastrar(ClienteRules $request){
  13.     $cliente = new AppClientes();
  14.     $cliente->nome = $request->nome;
  15.     $cliente->descricao = $request->descricao;
  16.     $cliente->vendedor = $request->vendedor;
  17.     $cliente->orcamento = $request->orcamento;
  18.     $cliente->save();
  19.     return redirect()->to('/lista_Cliente');
  20.  
  21. }
  22.      
  23. <?php
  24.  
  25. namespace AppHttpRequests;
  26.  
  27. use IlluminateFoundationHttpFormRequest;
  28.  
  29. class ClienteRules extends FormRequest
  30. {
  31. /**
  32.  * Determine if the user is authorized to make this request.
  33.  *
  34.  * @return bool
  35.  */
  36. public function authorize()
  37. {
  38.     return true;
  39. }
  40.  
  41. /**
  42.  * Get the validation rules that apply to the request.
  43.  *
  44.  * @return array
  45.  */
  46. public function rules()
  47. {
  48.     return [
  49.         'nome' => 'required',
  50.         'descricao' => 'required',
  51.         'vendedor' => 'required',
  52.         'orcamento' => 'required'
  53.     ];
  54. }
  55. public function messages(){
  56.     return[
  57.         'nome.required' => 'Informe seu nome.',
  58.         'descricao.required' => 'Informe a descriĆ§Ć£o do produto.',
  59.         'vendedor.required' => 'Informe o nome do vendedor.',
  60.         'orcamento.required' => 'Informe o orƧamento.'
  61.  
  62. ];
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top