PHP code example of gheith3 / filament-relation-pages
1. Go to this page and download the library: Download gheith3/filament-relation-pages library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gheith3 / filament-relation-pages example snippets
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,
// ...
];
}