How to register Pages to Filament from Database?

I am developing a simple CMS for the admin panel. I want to store custom pages and their data on database . I hope to register those pages to filament in a service provider so those pages must be visible in admin panel. Any help?
4 Replies
Dennis Koch
Dennis Koch2y ago
Why don't you just use a PageResource? Do you really want a single nav item for every page you have? If so, check the docs for custom navigation.
prageeth94
prageeth94OP2y ago
So far this will create new page to a the admin panel
php
<?php

namespace App\Providers;

use App\Filament\Pages\TestPage;
use Filament\Facades\Filament;
use Filament\Pages\Page;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{

$page = new class extends Page{


protected static function getNavigationUrl(): string
{
return 'blah-blah';
}

protected static function getNavigationLabel(): string
{
return "Bla Bla Page";
}


};
Filament::registerPages([get_class($page)]);


}
}
php
<?php

namespace App\Providers;

use App\Filament\Pages\TestPage;
use Filament\Facades\Filament;
use Filament\Pages\Page;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{

$page = new class extends Page{


protected static function getNavigationUrl(): string
{
return 'blah-blah';
}

protected static function getNavigationLabel(): string
{
return "Bla Bla Page";
}


};
Filament::registerPages([get_class($page)]);


}
}
Dennis Koch
Dennis Koch2y ago
I still don't get why you want your CMS Pages to be Filament Pages? Also please read #✅┊rules on how to format code.
prageeth94
prageeth94OP2y ago
Sure. Actually I Just want to create dynamic admin pages. so technically it is not a cms i guess any idea to fix routing issue this way ? it gives 404 seems like i was going in the wrong direction. easy way to do is create a base page and load content using query parameters

Did you find this page helpful?