gheith3/filament-relation-pages
Filament Relation Pages lets you add fully custom, free-form tabs alongside Relation Managers in any resource—no forced table or relationship. Build pages with Filament schema components, Blade/HTML, Alpine.js, and more. Includes an artisan generator.
Add fully custom, free-form tabs alongside your Relation Managers in any Filament resource — no forced table, no forced relationship. Use Filament schema components, plain HTML, Alpine.js, or anything you like.
| Package | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^12.0 | ^13.0 |
| Filament | ^4.0 | ^5.0 |
composer require gheith3/filament-relation-pages
The service provider is auto-discovered by Laravel — no manual registration needed.
php artisan make:filament-relation-page BuildingSummaryPage --resource=Buildings
This creates two files:
app/Filament/Resources/Buildings/RelationPages/BuildingSummaryPage.php
resources/views/filament/resources/buildings/building-summary-page.blade.php
Open the generated PHP class and add your content:
use gheith3\FilamentRelationPages\RelationPage;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Contracts\View\View;
class BuildingSummaryPage extends RelationPage
{
protected static ?string $title = 'Summary';
protected static string|BackedEnum|null $icon = 'heroicon-o-chart-bar';
public function content(Schema $schema): Schema
{
return $schema->components([
Section::make('Overview')->columns(3)->schema([
TextEntry::make('name')->state($this->ownerRecord->name),
TextEntry::make('units')->state($this->ownerRecord->units()->count()),
]),
]);
}
public function render(): View
{
return view('filament.resources.buildings.building-summary-page');
}
}
// app/Filament/Resources/BuildingResource.php
public static function getRelations(): array
{
return [
RelationPages\BuildingSummaryPage::class, // ← custom tab
RelationManagers\UnitsRelationManager::class,
// ...
];
}
That's it. The tab appears in the tab bar alongside your relation managers.
The generated Blade view has two rendering modes:
<div class="space-y-6 p-2">
{{-- Option A: Filament components — powered by content(Schema $schema) --}}
{{ $this->content }}
{{-- Option B: Plain HTML — access the model via $this->ownerRecord --}}
<div class="p-6">
<h3>{{ $this->ownerRecord->name }}</h3>
</div>
</div>
Both modes can be mixed in the same view.
protected static ?string $title = 'My Tab';
protected static ?string $icon = 'heroicon-o-chart-bar';
protected static ?string $badge = null; // static badge text
protected static ?string $badgeColor = 'info';
Override getBadge() to compute the badge at runtime:
public static function getBadge(Model $ownerRecord, string $pageClass): ?string
{
return (string) $ownerRecord->items()->count();
}
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
return $ownerRecord->is_active;
}
Set $isLazy = true to defer rendering the tab content until the tab is first visited, exactly like Filament's own RelationManager:
protected static bool $isLazy = true;
You can define multiple schema methods — each becomes independently renderable in Blade:
public function stats(Schema $schema): Schema { ... }
public function details(Schema $schema): Schema { ... }
{{ $this->stats }}
{{ $this->details }}
public static function getDefaultProperties(): array
{
return ['mode' => 'compact'];
}
// Then in the class:
public string $mode = 'compact';
# Standard usage
php artisan make:filament-relation-page BuildingSummaryPage --resource=Buildings
# Interactive — prompts for resource name
php artisan make:filament-relation-page BuildingSummaryPage
# Multi-panel apps — places the file inside app/Filament/Admin/Resources/...
php artisan make:filament-relation-page BuildingSummaryPage --resource=Buildings --panel=admin
# Overwrite existing files without being prompted
php artisan make:filament-relation-page BuildingSummaryPage --resource=Buildings --force
Publish the stubs to your project to customise the generated templates:
php artisan vendor:publish --tag=filament-relation-pages-stubs
Stubs are published to stubs/filament-relation-pages/.
Filament calls three static methods on every entry in getRelations():
| Method | Purpose |
|---|---|
canViewForRecord() |
Should the tab be visible for this record? |
getTabComponent() |
Returns the Tab with label / icon / badge |
getDefaultProperties() |
Extra Livewire props merged on mount |
isLazy() |
Whether to lazy-load the tab content |
Then Filament mounts the class as a Livewire component, injecting ownerRecord and pageClass automatically. RelationPage implements HasSchemas + HasActions — the same stack Filament's own RelationManager uses — so all Filament form and infolist components work out of the box.
See CHANGELOG.md.
See CONTRIBUTING.md.
See SECURITY.md.
MIT — see LICENSE.md.
How can I help you explore Laravel packages today?