Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Hasmany To Modal Laravel Package

boydreams/hasmany-to-modal

Laravel package for managing HasMany relationships through modals. Open related records from a parent model and create, edit, or review them without leaving the page, making admin panels and inline workflows cleaner and faster.

View on GitHub
Deep Wiki
Context7

Getting Started

This is a Laravel Nova field that swaps the default HasMany index screen for a modal popup: instead of navigating away from the parent resource, you get a Nova-styled modal containing the related resource's index (and typically its actions/attached toolbar). Treat it as a drop-in replacement for Nova\Fields\HasMany in the fields() method of a parent Resource.

Minimal setup:

composer require boydreams/hasmany-to-modal

There is no service provider to publish in most Nova field packages, but confirm the package's composer.json extra.laravel.providers entry (Nova fields don't usually need one — they self-register via Nova's field discovery). After install, reference the class in your Resource:

use Boydreams\HasManyToModal\HasManyToModal;
// namespace may differ — check the package's src/ directory

public function fields(NovaRequest $request)
{
    return [
        // ... other fields
        HasManyToModal::make('Posts', 'posts', Post::class),
    ];
}

Where to look first:

  1. src/ — find the field class and read its component() method. That tells you the Vue component name, which maps to resources/js/components/ in the package (or vendor/ path if compiled).
  2. README.md — check for a supported Nova version and required constructor signature (arg order varies: make($name, $attribute, $resourceClass) vs make($name, $resource, $resourceClass)).
  3. dist/js/ — confirm the compiled JS ships with the package. If not, you'll need npm run build inside vendor/boydreams/hasmany-to-modal, which is a red flag for a 5-star package.

First use case: Use it on a User detail page where each user has many Orders. Instead of a full-page redirect to the Orders index, clicking "Orders (12)" opens a modal with the orders table, search, filters, and per-row actions — keeping the user's context on the parent record. This is where it shines: low-friction drilldowns on high-traffic detail screens.

Implementation Patterns

Basic replacement. The most common pattern is swapping out HasMany 1:1 in the parent Resource:

HasManyToModal::make('Comments', 'comments', Comment::class)
    ->modalSize('7xl'), // if the package exposes sizing; otherwise check component props

Controlling which columns the related resource shows. The modal renders the related resource's indexQuery and index fields, so column customization happens in the child Resource, not on the field. Create a dedicated "modal-friendly" resource if the default index is too wide:

// In Comment resource, guard on request context if needed
public function fields(NovaRequest $request) { ... }

Action and filter parity. Because the modal hosts the related Resource's index, attached Actions and Lenses/Filters on the child Resource should appear. Pattern: put a ModalCommentResource wrapper (a subclass with trimmed fields) and pass it as the third argument so the popup stays compact while the full resource keeps its detail-rich index.

Integration with computed/dependent fields. If you only want the popup sometimes, conditionally return the field:

$this->when($user->orders()->exists(), fn () => HasManyToModal::make(...));

Or gate it with ->canSee(fn () => $request->user()->isAdmin()) — Nova policies still apply to the related resource, so authorization rules run inside the modal as expected. Confirm the package forwards Nova's authorization (it may bypass the parent's field-level policies).

Dashboarding pattern. Combine with ->hideFromDetail() / ->showOnDetail() (standard Nova field methods) for use on detail screens only. Because it's rendering an embedded index, modal size and mobile behavior matter — test on tablet widths before shipping; the default Nova modal can overflow narrow screens.

Pairing with inline creation. If the related resource has a create action, verify it still works inside the modal. Many "HasMany to modal" fields rely on the embedded resource index's "Create" button, and clicking it should keep the flow inside the modal. If it breaks out to a full page, that's the primary extension point to patch.

Gotchas and Tips

  • Version compatibility is the biggest risk. With 5 stars, 0 dependents, and a repository name suggesting it was built against a specific Nova major (likely 4.x), assume it breaks on Nova 5. Check the package's composer.json for laravel/nova constraint and test against your exact Nova version before adopting. There is no guaranteed maintenance cadence.

  • Nova is commercial and closed-source. Nova field packages frequently reference Laravel\Nova\Fields\HasMany internals; if Nova updated those internals, a small package like this will silently fail (blank modal, broken component). Debugging step: inspect the modal's Vue component in browser devtools and check the console for "unknown component" or prop-type errors.

  • Compiled assets must be present. Nova fields ship compiled JS; if dist/js/field.js is missing from the package, you have to build it yourself, which is a poor day-to-day story. Check the vendor directory immediately after install.

  • Attribute vs. relationship argument order. Constructor signatures vary between these packages — some take make($name, $attribute, $resourceClass), others make($name, $resourceClass, $relationship). A wrong order yields a confusing "relationship not found" or a modal showing the wrong resource. Read the field class __construct rather than trusting the README.

  • Authorization and policies. Nova policies on the related resource govern the modal's actions, but field-level canSee on the parent may not be respected if the package overrides Nova's base HasMany behavior. Verify with php artisan nova:test or a quick policy check.

  • Performance with large HasMany sets. The modal loads the related index on open; if the related resource has no pagination override or is heavy (e.g. eager loads not set), the popup will lag. Set $perPage on the related resource and add indexes on the foreign key column.

  • Search and filters inside the modal. Confirm the related resource's filters work inside the modal container — some modals don't forward the query string properly, so filters apply but the modal doesn't re-render. This is the most common functional bug in these packages.

  • Extension points to inspect: the field's component() return value, any resolveUsing/fillUsing overrides, and whether the package exposes a config file (php artisan vendor:publish --tag=...). If nothing is published, patching means forking — factor that into your maintenance budget given the low star count.

  • Fallback plan. If the package doesn't hold up, the standard Nova idiom is HasMany::make(...)->hideFromDetail() with a custom Lens or a bespoke field pointing a modal component at the related resource's URL — worth building your own before committing to an unmaintained dependency.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log