php-tenant/View/Modal/Web/WorkspaceHome.php
Snider a24ee4bfa8
Some checks failed
CI / PHP 8.3 (pull_request) Failing after 3s
CI / PHP 8.4 (pull_request) Failing after 3s
fix(tenant): add strict_types and fix PSR-12 compliance across all PHP files
Added declare(strict_types=1) to 27 files that were missing it.
Ran Pint to fix PSR-12 issues (import ordering, operator spacing, brace
positioning) across 33 files.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-17 09:11:54 +00:00

69 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace Core\Tenant\View\Modal\Web;
use Core\Mod\Content\Services\ContentRender;
use Core\Tenant\Models\Workspace;
use Core\Tenant\Services\WorkspaceService;
use Livewire\Component;
class WorkspaceHome extends Component
{
public array $workspace = [];
public array $content = [];
public bool $loading = true;
public function mount(?string $workspace = null): void
{
$workspaceService = app(WorkspaceService::class);
// Get workspace from route param or request attributes (from subdomain middleware)
$slug = $workspace ?? request()->attributes->get('workspace', 'main');
$this->workspace = $workspaceService->get($slug) ?? $workspaceService->get('main');
// Load workspace content from native content
$this->loadContent();
}
protected function loadContent(): void
{
try {
$workspaceModel = Workspace::where('slug', $this->workspace['slug'])->first();
if (! $workspaceModel) {
$this->content = ['posts' => [], 'pages' => []];
$this->loading = false;
return;
}
$render = app(ContentRender::class);
$homepage = $render->getHomepage($workspaceModel);
$this->content = [
'posts' => $homepage['posts'] ?? [],
'pages' => [], // Pages not included in homepage response
];
} catch (\Exception $e) {
$this->content = [
'posts' => [],
'pages' => [],
];
}
$this->loading = false;
}
public function render()
{
return view('tenant::web.workspace.home')
->layout('components.layouts.workspace', [
'title' => $this->workspace['name'].' | Host UK',
'workspace' => $this->workspace,
]);
}
}