A Laravel Nova field for searchable has-many relationships
metasync-site/nova-has-many-searchable is a Laravel package for a laravel nova field for searchable has-many relationships.
It currently has 1 GitHub stars and 2.495 downloads on Packagist (latest version v1.0.5).
Install it with composer require metasync-site/nova-has-many-searchable.
Discover more Laravel packages by metasync-site
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel Nova field that provides a searchable interface for has-many relationships with the ability to create new related resources.

You can install the package via composer:
composer require metasync-site/nova-has-many-searchable
use MetasyncSite\NovaHasManySearchable\HasManySearchable;
public function fields(NovaRequest $request)
{
return [
HasManySearchable::make('Coupons')
->relationshipConfig(
resourceClass: CouponsResource::class,
foreignKey: 'GoodsDataId',
displayCallback: function ($coupon) {
return "{$coupon?->Name} (Type: {$coupon->Type})";
}
)
->withCreateButton(true, 'Create New Coupon'),
];
}
You can customize how each option is displayed using the displayCallback:
HasManySearchable::make('Coupons')
->relationshipConfig(
resourceClass: CouponsResource::class,
foreignKey: 'GoodsDataId',
displayCallback: fn($model) => "{$model->name} ({$model->code})"
)
Enable the create button with an optional custom label:
HasManySearchable::make('Coupons')
->withCreateButton(true, 'Add New Coupon')
If you discover any security vulnerabilities, please email [email protected]