fieldName = $fieldName; $this->label = $label; } public function updatedImage() { $this->validate([ 'image' => 'image|max:2048', // 2MB Max ]); // Subir automáticamente al seleccionar $this->uploadImage(); } public function uploadImage() { $this->validate([ 'image' => 'required|image|max:2048', ]); // Guardar la imagen $this->imagePath = $this->image->store('uploads', 'public'); // Emitir evento con el nombre del campo y la ruta $this->dispatch('imageUploaded', field: $this->fieldName, path: $this->imagePath ); } public function save() { $this->validate([ 'image' => 'required|image|max:2048', ]); // Guardar la imagen $this->imagePath = $this->image->store('images', 'public'); // Emitir evento con el nombre del campo y la ruta $this->emit('imageUploaded', [ 'field' => $this->fieldName, 'path' => $this->imagePath ]); } public function removeImage() { $this->reset(['image', 'imagePath']); // Cambiar emit por dispatch en Livewire v3+ $this->dispatch('imageRemoved', field: $this->fieldName ); } public function toggleHover($status) { $this->hover = $status; } public function render() { return view('livewire.image-uploader'); } }