'nullable|string', 'pre_tag_xml' => 'nullable|string', 'tag_xml' => 'nullable|string', 'type_field' => 'nullable|string', 'format_field' => 'nullable|string', 'name' => 'nullable|string', 'thai_name' => 'nullable|string', 'description' => 'nullable|string', 'uploadFilePathName1' => 'nullable|file|max:10240', ]; public function mount($editId) { $master = MasterMapfieldXml::find($editId); $this->recordId = $editId; $this->xml_type = $master->xml_type; $this->pre_tag_xml = $master->pre_tag_xml; $this->tag_xml = $master->tag_xml; $this->type_field = $master->type_field; $this->format_field = $master->format_field; $this->name = $master->name; $this->thai_name = $master->thai_name; $this->description = $master->description; $this->uploadFilePathName1 = $master->img; } public function uploadImage($file) { $originalName = $file->getClientOriginalName(); $path = $file->storeAs('images/error-tran', $originalName, 'public'); return asset('storage/' . $path); } public function submitForm() { $this->validate(); if ($this->uploadFilePathName1 instanceof \Illuminate\Http\UploadedFile) { $originalName = $this->uploadFilePathName1->getClientOriginalName(); $filePath1 = $this->uploadFilePathName1->storeAs('images/error-tran', $originalName, 'public'); $this->uploadFilePathName1 = $filePath1; } MasterMapfieldXml::updateOrCreate( ['id' => $this->recordId], [ 'xml_type' => $this->xml_type, 'pre_tag_xml' => $this->pre_tag_xml, 'tag_xml' => $this->tag_xml, 'type_field' => $this->type_field, 'format_field' => $this->format_field, 'name' => $this->name, 'thai_name' => $this->thai_name, 'description' => $this->description, 'img' => $this->uploadFilePathName1, ] ); $this->resetForm(); $this->emit('showList', 'Successfully updated.'); } public function removeFile($fileName) { if ($this->$fileName) { if ($this->$fileName instanceof \Illuminate\Http\UploadedFile) { $this->$fileName = null; } else { Storage::disk('public')->delete($this->$fileName); $this->$fileName = null; } } } public function resetForm() { $this->mount($this->recordId); } public function goBack() { $this->emit('showList'); } public function render() { return view('livewire.pages.master-file-xml.master-file-edit'); } }