shivanshrajpoot/nova-create-or-add
A Laravel Nova field that lets you create a new related resource or attach an existing one directly from a relationship form, streamlining inline workflows without leaving the parent resource.
BelongsTo field forces a context switch (save parent → navigate → create child → return) or a silent validation failure. The decision it informs is narrow but measurable — "is reducing operator context-switching worth engineering time?" — and can be tracked in time-to-create for parent records and in support tickets phrased "I can't find X in the dropdown."laravel/nova.Evaluate it only when all of the following hold:
composer.json constraint against your Nova major. A permissive or missing constraint (*) is a red flag, not a green light — it usually means compatibility was never reasoned about.BelongsTo / MorphTo). For BelongsToMany attach semantics, nested creation, or multi-record creation, this is the wrong tool — route that to a Nova action or a custom tool.packages/ path repository or private VCS fork, pin it, and add a smoke test covering create, attach-existing, validation failure, and policy denial.Look elsewhere — or ship nothing — when:
BelongsTo::searchable() plus Nova's built-in create-relation affordance handles the common case. Verify first; it's free, supported, and gates everything else. If it works, close the ticket — that's a two-hour check well spent.routes/ and any controllers before the README: a bespoke create endpoint that skips the policy layer is the highest-severity finding in a diligence pass like this.DB::transaction() boundary or an unscoped search endpoint on a high-cardinality table, build the minimal in-house field instead — replacement cost stays 1–2 dev-days.To executives: This is a small ergonomics fix for our internal admin tooling — it lets ops staff create a missing related record without leaving the form they're already on. It's not customer-facing and not a strategic bet. Cost is roughly a day of engineering whichever route we take, and it's fully reversible: the field drops in as a one-line swap against the native BelongsTo we already use, and rolls back the same way. Recommendation: vendor the pattern rather than take a direct dependency on a nine-star, single-maintainer package. Low upside, low downside, bounded cost.
To engineering: Treat this as a source read first, install second. The valuable part is the interaction pattern, not the artifact. Concretely: confirm the PHP field extends BelongsTo (so we inherit search, nullable, and rules behavior), confirm the inline create posts through Nova's standard resource store route so the related model's create policy and validation actually run, and confirm create-then-attach is wrapped in a transaction. If any of those three checks fail, fork and patch — it's cheaper than reimplementing. Then vendor it, pin it, add Dependabot for laravel/nova and laravel/framework, and put a six-path smoke test in CI (create, attach-existing, validation failure preserving parent form state, policy denial, nullable left empty, double-submit producing no duplicate). Roll out behind a flag, one resource at a time, and remember the classic silent failure mode: a stale published asset after a Nova upgrade, where the field simply stops responding with no exception and no log line.
To the operations team: The change you'll notice is that you stop losing your work. Today, when the vendor or contact you need isn't in the dropdown, you either abandon the form to go create it or you get bounced on save. After this, you create it inline and keep going — one flow instead of three screens. We'll pilot it on one resource first, and if the inline-create validation errors ever wipe a half-typed form, tell us immediately; that's the failure mode we care most about and it's the one we'll be testing for.
How can I help you explore Laravel packages today?