Files
RomhackPlaza/app/Livewire/EntryFilesModal.php

38 lines
741 B
PHP
Raw Normal View History

<?php
namespace App\Livewire;
use App\Models\Entry;
use Livewire\Component;
class EntryFilesModal extends Component
{
public bool $open = false;
public ?int $entryId = null;
protected $listeners = [
'entryOpenFilesModal' => 'openModal'
];
public function openModal( int $entryId ): void
{
$this->entryId = $entryId;
$this->open = true;
$this->dispatch('modal:opened');
}
public function close(): void
{
$this->open = false;
$this->entryId = null;
}
public function render()
{
$files = $this->entryId ? Entry::find($this->entryId)?->files : collect();
return view('livewire.entry-files-modal', compact('files'));
}
}