- How do I install benjacho/belongs-to-many-field in Laravel Nova?
- Install it with composer require benjacho/belongs-to-many-field. In a standard Laravel Nova installation you do not need to manually register the service provider. After installation, add the field to a Nova resource's fields() method and confirm the underlying belongsToMany relationship and pivot keys are correct.
- Which Laravel, PHP, and Nova versions does this BelongsToMany field support?
- The package was last released on 2023-02-24 as version 3.0.1-beta, and the available context does not show a current CI support matrix. Nova has advanced through major versions since then, so the validated matrix is likely behind your stack. Treat your exact Laravel, PHP, and Nova versions as unproven until you run a spike or integration test.
- How do I use BelongsToManyField in a Laravel Nova resource?
- Add BelongsToManyField::make('Tags', 'tags', Tag::class) to the resource's fields() method, where tags is a real belongsToMany relationship. The related table should have an indexed, human-readable label column for search. If you plan to edit pivot attributes, declare them with withPivot() on the Eloquent model.
- Should I use options() or label() with searchable() for a BelongsToMany field?
- Use options() for small fixed or tenant-scoped sets such as roles, statuses, or curated categories. Use label() plus searchable() for large dynamic related tables. This choice should be documented and reviewed per resource because getting it wrong is where most operational risk lands.
- Does this Nova field support creating related models inline?
- Yes, the field supports inline creation of related models. Inline creation can bypass Nova policies and model validation unless it is explicitly configured and tested. Assess that authorization and governance gap per resource before rollout rather than discovering it during an audit.
- Can I edit pivot table attributes with Benjacho's BelongsToMany field?
- The prerequisite is that the Eloquent model declares the pivot attributes with withPivot(). The field is designed for Nova belongsToMany editing, and the relationship plus pivot foreign keys must already be correct. Test pivot editing against your Nova version because the package is a beta release from 2023.
- How does searchable() perform with 10,000+ related records?
- The available context does not confirm whether searchable() paginates and queries server-side or hydrates the full option set in the browser. Measure query counts, payload size, and render time at your real data volume before production. If the picker truncates, mis-searches, or fails silently, treat it as a data-integrity risk rather than a cosmetic UI issue.
- Is benjacho/belongs-to-many-field still maintained and production-ready?
- The package has a bus factor of one, no vendor SLA, and no published security process, with its last release in February 2023 as 3.0.1-beta. It is MIT licensed, so forking and patching is legally cheap, but the engineering cost of that exit lands on your team. Adoption is reversible per resource and per field, which limits blast radius but does not remove staleness risk.
- How do I show selected models as badges or a list in Nova?
- Use displayAsBadges() to render selected related models as badges or displayAsList() to render them as a list. These are presentation options on the field and do not change the underlying belongsToMany relationship. Keep the choice consistent with the rest of the Nova resource UI.
- Can I use this package without Laravel Nova, or what alternatives should I consider?
- No, this is a Laravel Nova field, so without a current Nova licence and installation the addressable use case is zero. Within Nova, compare it with the native BelongsToMany attach and detach workflow and with building or forking a custom field. Because the package is MIT licensed, forking and patching is a viable exit if the field otherwise fits your admin surfaces.