eminiarts/nova-relationship-selector

Laravel Nova 扩展包,用于将关系分组到选择器中。


README

Latest Version on Github Total Downloads

使用下拉菜单显示资源的关联关系,而不是无限滚动。

image

安装

您可以通过 composer 将此包安装到使用 Nova 的 Laravel 应用中。

composer require eminiarts/nova-relationship-selector

用法

use Eminiarts\RelationshipSelector\RelationshipSelector;
public function fields()
{
    return [
        
        // ...
        
        RelationshipSelector::make('Relations')
            ->addOption('Invoices', HasMany::make('Invoices'))
            ->addOption('Notes', HasMany::make('Notes'))
            ->addOption('Contacts', HasMany::make('Contacts'))
            ->addOption('Tags', MorphToMany::make('Tags')),
        
        // ...
        
    ];
}

与 Select 结合使用

如果您想在右侧显示 Select,可以使用 ->withSelect() 函数。

image