PHPackages                             metasync-site/nova-belongs-to-many - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. metasync-site/nova-belongs-to-many

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

metasync-site/nova-belongs-to-many
==================================

A Laravel Nova field for searchable belongs-to-many relationships

1.0.6(6mo ago)32.1k↓50%2MITPHPPHP &gt;=8.2

Since Jan 30Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/metasyncSite/nova-belongs-to-many)[ Packagist](https://packagist.org/packages/metasync-site/nova-belongs-to-many)[ RSS](/packages/metasync-site-nova-belongs-to-many/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

Laravel Nova BelongsToMany Searchable Field
===========================================

[](#laravel-nova-belongstomany-searchable-field)

A Laravel Nova field that provides a searchable interface for belongs-to-many relationships with the ability to create new related resources.

[![screenshot of the search relations tool](./screenshot.png)](./screenshot.png)

Requirements
------------

[](#requirements)

- PHP &gt;=8.2
- Laravel 11.x | 12.x
- Laravel Nova 4.x | 5.x

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require metasync-site/nova-belongs-to-many
```

Usage
-----

[](#usage)

```
use MetasyncSite\NovaBelongsToMany\BelongsToManySearchable;

 BelongsToManySearchable::make('Products')
            ->relationshipConfig(
                resourceClass: ProductResource::class,
                relationName: 'products',
            ),
```

### Full api

[](#full-api)

```
use MetasyncSite\NovaBelongsToMany\BelongsToManySearchable;

public function fields(NovaRequest $request)
{
    return [
        BelongsToManySearchable::make('Products')
            ->relationshipConfig(
                resourceClass: ProductResource::class,
                relationName: 'products',
                pivotTable: 'category_product',
                foreignPivotKey: 'category_id',
                relatedPivotKey: 'product_id',
                displayCallback: fn($product) => "{$product->name} (${$product->price})"
            )
            ->withCreateButton(true, 'Add New Product'),
    ];
}
```

Features
--------

[](#features)

- 🔍 Searchable interface for belongs-to-many relationships
- ✨ Custom display formatting with callback support
- ➕ Optional "Create New" button with modal
- 🎨 Dark mode support
- 🎯 Type-safe implementation
- 🔄 Automatic pivot table management

Configuration Options
---------------------

[](#configuration-options)

### Required Parameters

[](#required-parameters)

- `resourceClass`: The Nova resource class for the related model
- `relationName`: The name of the relationship method on your model
- `pivotTable`: The name of the pivot table
- `foreignPivotKey`: The foreign key of the parent model in the pivot table
- `relatedPivotKey`: The foreign key of the related model in the pivot table

### Optional Parameters

[](#optional-parameters)

- `displayCallback`: Customize how each option is displayed
- `withCreateButton`: Enable the create button with an optional custom label

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover any security vulnerabilities, please email

Credits
-------

[](#credits)

- [Metasync](https://github.com/metasyncSite)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance69

Regular maintenance activity

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~72 days

Total

7

Last Release

182d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d463f04fe31693ccfacd94a07abaae0d45a680b0895afc579138b83e5a13364?d=identicon)[metasyncSite](/maintainers/metasyncSite)

---

Top Contributors

[![gerasart](https://avatars.githubusercontent.com/u/8726693?v=4)](https://github.com/gerasart "gerasart (7 commits)")[![metasyncSite](https://avatars.githubusercontent.com/u/157399850?v=4)](https://github.com/metasyncSite "metasyncSite (2 commits)")

---

Tags

laravelsearchablefieldnovabelongs-to-many

### Embed Badge

![Health badge](/badges/metasync-site-nova-belongs-to-many/health.svg)

```
[![Health](https://phpackages.com/badges/metasync-site-nova-belongs-to-many/health.svg)](https://phpackages.com/packages/metasync-site-nova-belongs-to-many)
```

###  Alternatives

[inspheric/nova-url-field

A Laravel Nova URL field.

1031.3M1](/packages/inspheric-nova-url-field)[alexwenzel/nova-dependency-container

A Laravel Nova 4 form container for grouping fields that depend on other field values.

461.0M2](/packages/alexwenzel-nova-dependency-container)[outl1ne/nova-simple-repeatable

A Laravel Nova simple repeatable rows field.

74356.3k](/packages/outl1ne-nova-simple-repeatable)[simplesquid/nova-enum-field

A Laravel Nova field to add enums to resources.

52391.9k2](/packages/simplesquid-nova-enum-field)[sietse85/nova-button

(Nova 4+) A Laravel Nova package for adding buttons to your resources.

37347.3k](/packages/sietse85-nova-button)[optimistdigital/nova-notes-field

This Laravel Nova package adds a notes field to Nova's arsenal of fields.

52139.5k](/packages/optimistdigital-nova-notes-field)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
