must not be accessed before initialization | 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 FILIPE

1 semana, 6 dias atrás FILIPE

must not be accessed before initialization

``` <?php namespace App\Http\Livewire\Consultation; use Livewire\Component; use App\Models\Consultation; class Index extends Component { public Consultation $consultation; protected $rules = [ 'consultation.date' => 'required|date|unique:consultations,date', 'consultation.weight' => 'required', 'consultation.height' => 'required', 'consultation.head_circuference' => 'required', 'consultation.doctor' => 'required', 'consultation.hospital' => 'required' ]; public function mount() { $this->consultation = new Consultation(); } public function updated($propertyName) { $this->validateOnly($propertyName); } public function save() { $this->validate(); Consultation::create($this->consultation->toArray()); $this->reset(); return redirect()->route('consultation.index'); } public function render() { return view('livewire.consultation.index'); } } ``` Não conseguir identificar o erro de must not be accessed before initialization. Pode me ajudar?

5 Respostas