<?php
namespace App\Filament\Pages;
use Filament\Pages\Page;
use Filament\Navigation\NavigationItem;
use Z3d0X\FilamentFabricator\Models\Page as FabricatorPage;
class FabricatorTest extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static ?string $title = '';
protected static string $view = 'filament.pages.fabricator-test';
protected $page;
public function mount($slug): void
{
$this->page = FabricatorPage::where('slug', $slug)->firstOrFail();
self::$title = $this->page->title;
}
public static function getNavigationItems(): array
{
$pages = FabricatorPage::all();
return $pages->map(function ($page) {
$request = (object) request();
logger($request);
// $tenantId = $request->route('tenant_id');
return NavigationItem::make($page->title)
->url(route('filament.pages.fabricator-test', ['tenant' => filament()->getTenant(), 'slug' => $page->slug]))
->isActiveWhen(fn (): bool => $request->route('slug') === $page->slug)
->icon('heroicon-o-document');
})->toArray();
}
protected function getViewData(): array
{
return [
'page' => $this->page,
];
}
}