mejoras
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
2025-05-23 00:26:53 +02:00
parent 19fa52ca65
commit 28c225687a
431 changed files with 161955 additions and 2096 deletions

View File

@@ -10,7 +10,6 @@ class ImageUploader extends Component
{
use WithFileUploads;
<<<<<<< HEAD
public $image;
public $imagePath;
public $fieldName; // Nombre del campo para el formulario
@@ -47,41 +46,10 @@ class ImageUploader extends Component
field: $this->fieldName,
path: $this->imagePath
);
=======
public $photo;
public $currentImage;
public $fieldName;
public $placeholder;
public $storagePath = 'tmp/uploads';
protected $rules = [
'photo' => 'nullable|image|max:2048', // 2MB Max
];
public function mount($fieldName = 'photo', $currentImage = null, $placeholder = null)
{
$this->fieldName = $fieldName;
$this->currentImage = $currentImage;
$this->placeholder = $placeholder ?? asset('images/default-avatar.png');
}
public function updatedPhoto()
{
$this->validate([
'photo' => 'image|max:2048', // 2MB Max
]);
}
public function removePhoto()
{
$this->photo = null;
$this->currentImage = null;
>>>>>>> f97a7a84985ea300216ba3ea2ab4c31306e1659a
}
public function save()
{
<<<<<<< HEAD
$this->validate([
'image' => 'required|image|max:2048',
]);
@@ -111,38 +79,6 @@ class ImageUploader extends Component
$this->hover = $status;
}
=======
$this->validate();
if ($this->photo) {
$path = $this->photo->store($this->storagePath);
if ($this->model) {
// Eliminar imagen anterior si existe
if ($this->model->{$this->fieldName}) {
Storage::delete($this->model->{$this->fieldName});
}
$this->model->{$this->fieldName} = $path;
$this->model->save();
}
$this->currentUrl = Storage::url($path);
$this->showSavedMessage = true;
$this->photo = null; // Limpiar el input de subida
}
}
protected function getCurrentImageUrl()
{
if ($this->model && $this->model->{$this->fieldName}) {
return Storage::url($this->model->{$this->fieldName});
}
return $this->placeholder;
}
>>>>>>> f97a7a84985ea300216ba3ea2ab4c31306e1659a
public function render()
{
return view('livewire.image-uploader');