Files
Nexora/app/Livewire/ProjectShow.php
Javi 356f56eebd
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
first commit
2025-04-23 00:14:33 +06:00

51 lines
1.1 KiB
PHP

<?php
namespace App\Livewire;
use Livewire\Component;
use App\Models\Project;
use App\Models\Folder;
use App\Models\Document;
class ProjectShow extends Component
{
public Project $project;
public $selectedFolderId = null;
public $expandedFolders = [];
public function mount(Project $project)
{
$this->project = $project->load('rootFolders');
}
public function selectFolder($folderId)
{
$this->selectedFolderId = $folderId;
}
public function toggleFolder($folderId)
{
if (in_array($folderId, $this->expandedFolders)) {
$this->expandedFolders = array_diff($this->expandedFolders, [$folderId]);
} else {
$this->expandedFolders[] = $folderId;
}
}
public function getDocumentsProperty()
{
return Document::where('folder_id', $this->selectedFolderId)
->where('project_id', $this->project->id)
->with('versions')
->get();
}
public function render()
{
return view('livewire.project-show', [
'rootFolders' => $this->project->rootFolders
]);
}
}