Skip to content
本页为翻译版本:如有出入,以英文文档为准。 阅读英文版

配置 ​

发布配置文件,即可修改所有 resource 的默认值:

bash
php artisan vendor:publish --tag=filament-relation-navigator-config

已发布的配置文件在各个 minor 版本之间都能继续使用:每个键在代码中都有默认值,因此只有当你想修改新键时才需要添加它们。

选项 ​

大多数选项也可以按 resource(resource 上的静态方法)或按页面或 relation manager 设置:

  • 菜单选项(有对应方法的 menu.*、记录导航、标签页重定向):页面优先,其次是 resource,最后是配置。
  • “作为页面打开” 和 relation manager 在菜单中的徽章:只有每一层都允许时才会显示;任何一层都可以关闭它们。
  • 全局搜索链接:resource 的方法会替代该 resource 的配置;relation manager 只能把自己排除在外。
  • 为上一条和下一条记住的列表:只由 resource 或配置决定,因为列表页面无法询问记录页面。
  • menu.presets、menu.search_from、menu.max_height 和 menu.separator 只能在配置中设置。
键默认值作用其他层级
menu.preset'github'菜单的外观:github、simple、你自己的预设或视图名称getRelationNavigatorPreset()
menu.presetssimple、github预设的名称和视图
menu.searchabletrue在列表顶部显示搜索框isRelationNavigatorSearchable()
menu.search_from0菜单项达到这个数量时才显示搜索框
menu.badges'lazy''lazy':徽章在菜单打开时加载;true:随页面加载;false:不显示hasRelationNavigatorBadges()、hasDeferredRelationNavigatorBadges();relation manager:hasRelationNavigatorBadge()
menu.max_height'24rem'列表开始滚动前的高度(CSS 长度)
menu.separatortrue记录页面和关联页面分成两组
menu.mobiletrue在小屏幕上,菜单显示在标题上方hasRelationNavigatorMobileMenu()
menu.shortcut'alt+shift+r'打开菜单的键盘快捷键;null:不使用getRelationNavigatorShortcut()
relation_manager_linktruerelation manager 表格上的“作为页面打开”操作resource hasRelationPageLinks(),relation manager hasRelationPageLink()
relation_manager_action带箭头的链接该操作的外观:style、label、icon、icon_position、color、size、new_tabconfigureRelationPageActionUsing()、configureRelationPageAction()
global_search_actionsfalse全局搜索结果下指向关联页面的链接:true 或每个结果的最大数量resource hasRelationPageGlobalSearchActions(),relation manager hasRelationPageGlobalSearchAction()
record_navigationfalse上一条和下一条记录按钮hasRelationNavigatorRecordNavigation()
record_navigation_follows_listtrue上一条和下一条按照用户进入时所在的列表切换shouldRelationNavigatorRecordNavigationFollowList()
redirect_relation_tabsfalse查看页面上的 ?relation=x 会打开关联页面shouldRedirectRelationNavigatorTabs()

页面方法是使用 HasRelationNavigator 的记录页面上的实例方法;在 resource 上,同一个方法是静态的,作用于它的所有页面。参见页面、resource 还是配置。

完整文件 ​

当前版本附带的配置文件(注释为英文):

php
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Breadcrumb menu
    |--------------------------------------------------------------------------
    |
    | `preset` picks one of `presets`:
    |
    | - github (default): the last breadcrumb stays text, a caret next to it
    |           opens a panel with a heading and a check on the current page
    |           (like GitHub's "Switch repository").
    | - simple: the last breadcrumb itself opens the list.
    |
    | `searchable` adds a search field on top of the list, whatever the
    | preset; Enter opens the first match. For the menu of 1.2 and earlier,
    | set `'preset' => 'simple'` and `'searchable' => false`.
    |
    | Add your own preset by pointing a name to any view, or publish the
    | package views and change them:
    |
    |     php artisan vendor:publish --tag=filament-relation-navigator-views
    |
    | A page can override these with getRelationNavigatorPreset(),
    | isRelationNavigatorSearchable() and hasRelationNavigatorBadges().
    |
    */

    'menu' => [

        'preset' => 'github',

        'presets' => [
            'simple' => 'filament-relation-navigator::menu.simple',
            'github' => 'filament-relation-navigator::menu.github',
        ],

        'searchable' => true,

        // With `searchable`, the search field appears from this many items.
        'search_from' => 0,

        // The relation managers' badges, as in their tabs. 'lazy' (default)
        // loads them when the menu opens, so the page renders without their
        // queries; true renders them with the page; false turns them off. A
        // relation manager can leave its badge out: hasRelationNavigatorBadge().
        'badges' => 'lazy',

        'max_height' => '24rem',

        // The record pages and the relation pages in two blocks.
        'separator' => true,

        // Filament hides the breadcrumbs on small screens: show the menu
        // above the page heading there.
        'mobile' => true,

        // Opens the menu from anywhere on the page, outside text fields:
        // modifiers (alt, shift, ctrl, meta, or mod: ⌘ on a Mac, Ctrl
        // elsewhere) plus a letter, a digit or / . , ; Null turns it off.
        // A shortcut of the panel's global search is ignored, never doubled.
        'shortcut' => 'alt+shift+r',

    ],

    /*
    |--------------------------------------------------------------------------
    | Relation managers on the record pages
    |--------------------------------------------------------------------------
    |
    | An "Open as page" action in the header of the table of every relation
    | manager that has its own page, on the view and edit pages. Per resource:
    | hasRelationPageLinks(); per relation manager: hasRelationPageLink().
    |
    */

    'relation_manager_link' => true,

    // Its look. `style`: link, button or icon_button (the label becomes a
    // tooltip). `label`: text or translation key (null: "Open as page",
    // translated). `icon`: any Filament icon, or null for none. For more,
    // RelationNavigator::configureRelationPageActionUsing() in a service
    // provider, or configureRelationPageAction() on a resource or a relation
    // manager.
    'relation_manager_action' => [
        'style' => 'link',
        'label' => null,
        'icon' => 'heroicon-m-arrow-up-right',
        'icon_position' => 'after',
        'color' => 'gray',
        'size' => null,
        'new_tab' => false,
    ],

    /*
    |--------------------------------------------------------------------------
    | Global search
    |--------------------------------------------------------------------------
    |
    | Links to the record's relation pages under its global search results:
    | false, true, or the most links to show per result. Per resource:
    | hasRelationPageGlobalSearchActions(); per relation manager:
    | hasRelationPageGlobalSearchAction(). They run the relation managers'
    | canViewForRecord() for every result.
    |
    */

    'global_search_actions' => false,

    /*
    |--------------------------------------------------------------------------
    | Previous and next record
    |--------------------------------------------------------------------------
    |
    | Two buttons before the header actions of the pages with the menu: they
    | open the previous or the next record on the same page. Off by
    | default: they add a few queries per render. Per page, override
    | hasRelationNavigatorRecordNavigation(); to change the records,
    | getRelationNavigatorRecordNavigationQuery(). Not for nested resources.
    |
    */

    'record_navigation' => false,

    // Previous and next follow the list the user came from (the list page,
    // or the parent's relation manager for a nested resource): its sort,
    // filters, search and tab (up to 100 records), instead of the key order.
    'record_navigation_follows_list' => true,

    /*
    |--------------------------------------------------------------------------
    | Links to relation manager tabs
    |--------------------------------------------------------------------------
    |
    | A link to a tab of the view or edit page (`/customers/1?relation=bills`)
    | opens the relation page instead (`/customers/1/bills`). Handy once the
    | relation pages replace the tabs; off by default.
    |
    */

    'redirect_relation_tabs' => false,

];

版本 1.8.1,发布于 2026-11-15 · MIT 许可证。