Skip to content
このページは翻訳です。内容に違いがある場合は、英語のドキュメントが正となります。 英語版を読む

リレーションページのカスタマイズ ​

1 つのリレーションのタイトル、サブ見出し、パンくずリスト ​

リレーションマネージャーは、ページクラスを使わずに、レコードをもとにして自分のページのこれらを設定できます。

php
class OrdersRelationManager extends RelationManager
{
    public static function getRelationPageTitle(Model $ownerRecord): string|Htmlable|null
    {
        return "{$ownerRecord->name} の注文";
    }

    public static function getRelationPageSubheading(Model $ownerRecord): string|Htmlable|null
    {
        return '直近 12 か月';
    }

    public static function getRelationPageBreadcrumb(Model $ownerRecord): ?string
    {
        return '注文';
    }
}

デフォルトのままにするには null を返します。自分で書いたページクラス(後述)がある場合は、その $title、$subheading、$breadcrumb が優先されます。メニューとタブは、リレーションマネージャーのタイトルを使い続けます。リレーショングループにはリレーションマネージャーがないため、そのページはグループのラベルを使います。

独自のページクラス ​

自動生成されるリレーションページで、ほとんどの用途に対応できます。タイトルやパンくずリスト、その他 Filament のページでできることを変更したい場合は、ページクラスを自分で書いてください。そのリソースでは、パッケージがそのクラスを使います。

bash
php artisan make:filament-relation-navigator CustomerResource
php
class CustomerRelationPage extends RelationPage
{
    protected static string $resource = CustomerResource::class;

    protected static ?array $relations = ['orders', 'invoices'];  // これらだけ
    protected static array $excludedRelations = ['notes'];         // これらは除外
}
php
public static function getPages(): array
{
    return [
        'index' => ListCustomers::route('/'),
        'view' => ViewCustomer::route('/{record}'),
        ...CustomerRelationPage::relationRoutes(),
    ];
}

このクラスは通常の Filament ページです。getTitle()、getBreadcrumbs()、getHeaderActions() をオーバーライドしたり、独自のトレイトを使ったりできます。

バージョン 1.8.1(2026-11-15 リリース)· MIT ライセンス。