Listagem não atualiza | Fórum | School of Net

Deseja poder participar de nosso fórum e tirar todas as suas dúvidas?
Clique aqui e assine nosso plano de acesso ilimitado. Saiba mais.

por Patrick Lorran Ramos Carvalho

1 ano, 5 meses atrás Patrick Lorran Ramos Carvalho

Listagem não atualiza

Estou tentando fazer um outro exemplo aqui, mas quando eu insiro um registro a listagem não atualiza Classe: ``` public $nome; public $email; public $telefone; protected $rules = [ 'nome' => 'min:5|required', 'email' => 'email|required', 'telefone' => 'required', ]; protected $messages = [ 'nome.min' => 'O nome deve ter no mínimo 5 caracteres', 'nome.required' => 'O nome é obrigatório', 'email.email' => 'O email deve ser válido', 'email.required' => 'O email é obrigatório', 'telefone.required' => 'O telefone é obrigatório', ]; public function render() { $clientes = Cliente::all(); return view('livewire.cadastro-cliente', [ 'clientes' => $clientes ]); } public function updated($input) { $this->validateOnly($input); } public function create() { $validatedData = $this->validate(); Cliente::create([ 'nome' => $this->nome, 'email' => $this->email, 'telefone' => $this->telefone, ]); } ``` Minha view ``` <div> Formulário de cadastro de cliente <form wire:submit.prevent='create'> <div class="form-group"> <label for="">Nome</label> <input type="text" class="form-control" wire:model="nome"> @error('nome') <small class="error">{{ $message }}</small> @enderror </div> <div class="form-group"> <label for="">E-mail</label> <input type="text" class="form-control" wire:model="email"> @error('email') <small class="error">{{ $message }}</small> @enderror </div> <div class="form-group"> <label for="">Telefone</label> <input type="text" class="form-control" wire:model="telefone"> @error('telefone') <small class="error">{{ $message }}</small> @enderror </div> <div class="form-group"> <button class="btn btn-success btn-outline" type="submit">Salvar</button> </div> </form> </div> <div> <table class="table"> <thead> <tr> <th>#</th> <th>Nome</th> <th>E-mail</th> <th>Telefone</th> </tr> </thead> <tbody> @foreach($clientes as $cliente) <tr> <td>{{$cliente->id}}</td> <td>{{$cliente->nome}}</td> <td>{{$cliente->email}}</td> <td>{{$cliente->telefone}}</td> </tr> @endforeach </tbody> </table> </div> ```

1 Respostas