mejoras
This commit is contained in:
@@ -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');
|
||||
|
||||
37
app/Livewire/PdfViewer.php
Normal file
37
app/Livewire/PdfViewer.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
|
||||
class PdfViewer extends Component
|
||||
{
|
||||
public $pdfUrl;
|
||||
public $currentPage = 1;
|
||||
public $totalPages = 1;
|
||||
public $zoomLevel = 1;
|
||||
|
||||
protected $listeners = ['pageChanged', 'annotationSaved'];
|
||||
|
||||
public function mount($pdfId)
|
||||
{
|
||||
$this->pdfUrl = Storage::disk('pdfs')->temporaryUrl($pdfId, now()->addMinutes(30));
|
||||
}
|
||||
|
||||
public function pageChanged($page)
|
||||
{
|
||||
$this->currentPage = $page;
|
||||
}
|
||||
|
||||
public function annotationSaved($data)
|
||||
{
|
||||
// Procesar y guardar anotaciones
|
||||
$this->emit('refreshAnnotations');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.pdf-viewer');
|
||||
}
|
||||
}
|
||||
@@ -240,16 +240,6 @@ 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' => [
|
||||
['name' => __('Projects'), 'url' => route('projects.index')],
|
||||
['name' => $this->project->name, 'url' => route('projects.show', $this->project)],
|
||||
],
|
||||
]);
|
||||
=======
|
||||
return view('livewire.project-show');
|
||||
>>>>>>> f97a7a84985ea300216ba3ea2ab4c31306e1659a
|
||||
return view('livewire.project.show');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user