Nuestro equipo especializado despúes de ciertos días de investigación y de recopilar de datos, encontramos la solución, deseamos que resulte de utilidad para tu plan.
Ejemplo: campo de entrada dinámica laravel-livewire
namespaceAppHttpLivewire;useLivewireComponent;useAppStudent;useAppHttpLivewireField;useIlluminateHttpRequest;classStudentsextendsComponentpublic$students,$first_name,$last_name,$student_id;public$updateMode=false;public$inputs=[];public$i=1;publicfunctionadd($i)$i=$i+1;$this->i=$i;array_push($this->inputs,$i);publicfunctionremove($i)unset($this->inputs[$i]);publicfunctionrender()$this->students=Student::all();returnview('livewire.students');privatefunctionresetInputFields()$this->first_name='';$this->last_name='';publicfunctionstore()$validatedDate=$this->validate(['first_name.0'=>'required','last_name.0'=>'required','first_name.*'=>'required','last_name.*'=>'required',],['first_name.0.required'=>'First name field is required','last_name.0.required'=>'Last name field is required','first_name.*.required'=>'First name field is required','last_name.*.required'=>'Last name field is required',]);foreach($this->first_nameas$key=>$value)Student::create(['first_name'=>$this->first_name[$key],'last_name'=>$this->last_name[$key]]);$this->inputs=[];$this->resetInputFields();session()->flash('message','Students Created Successfully.');?>
Tienes la opción de animar nuestra publicación mostrando un comentario y dejando una valoración te lo agradecemos.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)