承接 gheith3/filament-relation-pages 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gheith3/filament-relation-pages

Composer 安装命令:

composer require gheith3/filament-relation-pages

包简介

A Filament plugin to add custom free-form pages as tabs alongside Relation Managers

README 文档

README

Latest Version on Packagist Total Downloads Tests License

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.

Relation Pages Demo

Relation Pages Demo

Requirements

Package Version
PHP ^8.2
Laravel ^12.0 | ^13.0
Filament ^4.0 | ^5.0

Installation

composer require gheith3/filament-relation-pages

The service provider is auto-discovered by Laravel — no manual registration needed.

Usage

1 — Generate a Relation Page

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

2 — Add Content to the Class

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');
    }
}

3 — Register in the Resource

// 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.

Blade View

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.

Available Features

Tab customisation

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';

Dynamic badge (from a query)

Override getBadge() to compute the badge at runtime:

public static function getBadge(Model $ownerRecord, string $pageClass): ?string
{
    return (string) $ownerRecord->items()->count();
}

Hide the tab conditionally

public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
    return $ownerRecord->is_active;
}

Lazy loading

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;

Multiple schemas in one page

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 }}

Pass extra Livewire data

public static function getDefaultProperties(): array
{
    return ['mode' => 'compact'];
}

// Then in the class:
public string $mode = 'compact';

Artisan Command Reference

# 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

Customising Stubs

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/.

How It Works

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.

Changelog

See CHANGELOG.md.

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md.

License

MIT — see LICENSE.md.

Author

Gheith

gheith3/filament-relation-pages 适用场景与选型建议

gheith3/filament-relation-pages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.36k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2026 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「panel」 「laravel」 「filament」 「filament-plugin」 「filamentphp」 「relation-manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 gheith3/filament-relation-pages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gheith3/filament-relation-pages 我们能提供哪些服务?
定制开发 / 二次开发

基于 gheith3/filament-relation-pages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 10
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-04