Merge branch 'main' of https://homehud.duckdns.org/javier/Nexora
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
2025-05-07 00:21:14 +02:00
11 changed files with 378 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ class ImageUploader extends Component
{
use WithFileUploads;
<<<<<<< HEAD
public $image;
public $imagePath;
public $fieldName; // Nombre del campo para el formulario
@@ -46,10 +47,41 @@ 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',
]);
@@ -79,6 +111,38 @@ 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');

View File

@@ -240,6 +240,7 @@ class ProjectShow extends Component
public function render()
{
<<<<<<< HEAD
return view('livewire.project.show')->layout('components.layouts.documents', [
'title' => __('Project: :name', ['name' => $this->project->name]),
'breadcrumbs' => [
@@ -247,5 +248,8 @@ class ProjectShow extends Component
['name' => $this->project->name, 'url' => route('projects.show', $this->project)],
],
]);
=======
return view('livewire.project-show');
>>>>>>> f97a7a84985ea300216ba3ea2ab4c31306e1659a
}
}