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

Nova Back To Parent Field Laravel Package

gwd/nova-back-to-parent-field

A Laravel Nova field that adds a convenient "back to parent" link to resource detail and form pages, letting you quickly navigate to the parent record instead of relying on breadcrumbs or manual URL edits.

View on GitHub
Deep Wiki
Context7

Getting Started

Confirm what you actually installed before writing any code. This package has no README, no marketplace listing, zero stars and a single release from 2020-08-23 — it was almost certainly built against Nova 3 (Laravel Mix era). Treat the source as the documentation.

  1. Install and inspect:

    composer require gwd/nova-back-to-parent-field
    composer show gwd/nova-back-to-parent-field
    cat vendor/gwd/nova-back-to-parent-field/composer.json
    ls -R vendor/gwd/nova-back-to-parent-field/src vendor/gwd/nova-back-to-parent-field/resources
    

    The three things you need from this pass: the field class namespace (likely Gwd\NovaBackToParentField\BackToParentField — verify, don't guess), the Nova version constraint, and whether a Nova::script() call exists so the Vue component is registered.

  2. First use case — a child resource detail page with a link back to its parent, e.g. an Order detail screen linking to its Customer:

    use Gwd\NovaBackToParentField\BackToParentField; // verify from src/
    
    public function fields(Request $request)
    {
        return [
            BackToParentField::make('Back to Customer')
                ->onlyOnDetail(),
    
            BelongsTo::make('Customer', 'customer', Customer::class),
            // ...
        ];
    }
    
  3. Read src/BackToParentField.php for the builder methods it exposes (parentResource(), parentId(), url() or similar). If none exist, the field infers the parent from the model relationship or from a BelongsTo field's position in the fields() array — that determines how you wire it.

If Nova 4/5 refuses to load the component (Unknown custom element in the console), stop here. The Vue component was compiled for Nova 3's asset pipeline and will need to be rebuilt as an ESM/Vite component. Budget for that before adopting.

Implementation Patterns

Navigation-only field. Keep this field purely presentational and let a normal BelongsTo handle editing. Never ship it on forms:

BackToParentField::make('Parent')
    ->onlyOnDetail()
    ->hideWhenCreating()
    ->hideWhenUpdating()
    ->hideFromIndex(),

Explicit parent resolution. If the field doesn't infer the parent reliably (or you want to control the label and URL), resolve it yourself in the callback:

BackToParentField::make('Parent')
    ->onlyOnDetail()
    ->resolveUsing(function ($value, $resource) {
        $parent = $resource->customer; // loadMissing first, see gotchas
        if (! $parent) {
            return null;
        }

        return [
            'label' => "{$parent->name}",
            'url'   => \Laravel\Nova\Nova::path()."/resources/customers/{$parent->getKey()}",
        ];
    });

Prefer Nova::path() / Nova::resourcePath()-style helpers over hard-coded /nova/resources/... so the field survives a change to the Nova path or a renamed resource URI key.

Multi-level hierarchies. For a tree (Category → Subcategory → Product), put the field on each level and derive the parent class from the model so a single field definition covers polymorphic parents:

$parentClass = $resource->parent_type
    ? Nova::resourceForModel($resource->parent_type)
    : Category::class;

Wrap it, don't fork the vendor directory. Subclass it once so fixes survive composer update, or if it's already broken, copy the class plus its Vue component into your app:

namespace App\Nova\Fields;

class BackToParent extends \Gwd\NovaBackToParentField\BackToParentField
{
    public function component()
    {
        return 'back-to-parent-field'; // your own registered component
    }
}

Then register the script in a service provider: Nova::script('back-to-parent', __DIR__.'/../dist/js/back-to-parent.js').

The 10-line replacement. For Nova 4/5, the cheapest equivalent is a Text field rendered as HTML, or a small Stack:

Text::make('Parent', function () {
    $p = $this->customer;
    return $p
        ? "<a class='link-default' href='".Nova::path()."/resources/customers/{$p->getKey()}'>&larr; {$p->name}</a>"
        : '';
})->asHtml()->onlyOnDetail(),

Gotchas and Tips

  • Abandoned and effectively undocumented. 0 stars, 0 dependents, one release in 2020. There is no support channel and no changelog. Verify the LICENSE file exists and grep -R "curl\|Http::\|file_get_contents" src/ before putting it in a production app.
  • Nova 4/5 incompatibility is the default expectation. Check composer.json for laravel/nova constraints and whether the JS is built with laravel-nova mix helpers. You cannot rebuild vendor JS from your app root — you must publish or copy it into your own asset pipeline.
  • It renders everywhere by default. A Nova field appears on index, create and update unless hidden. Without onlyOnDetail() you'll get a stray column and possibly errors on the create form where no parent exists yet.
  • Don't let it be sortable or searchable. If the field reports a column that doesn't exist, index requests will generate invalid SQL and 500. Explicitly ->sortable(false) / avoid searchable().
  • N+1 queries on the index/detail screen. The field touches the parent relationship per row. Add $resource->loadMissing('customer') in the resolver, or eager-load in the resource via $this->load() / index query scoping.
  • Authorize the target. The link must not point at a resource the current user can't view. Gate::allows('view', $parent) (or Nova::resourceForModel() + policy check) before returning a URL — otherwise you're leaking navigable paths.
  • Component registration failures are silent-ish. If nothing renders, check the browser console for Unknown custom element: <back-to-parent-field>, confirm Nova::script() runs, then php artisan nova:publish and hard-refresh. Nova caches assets; clear with php artisan view:clear plus a browser cache bust.
  • Ordering matters if it infers from a sibling field. If the class reads the resource's fields() array to find a BelongsTo, place it after that field — a subtle, undocumented coupling worth a comment in your resource.
  • Pin it. Use an exact version in composer.json ("gwd/nova-back-to-parent-field": "1.0.0") and run composer require --dry-run first to confirm it resolves against your Nova version. An unpinned abandoned package is a future composer update landmine.
  • Replacement is cheap. Because the entire value proposition is one anchor tag, the maintenance burden of keeping this alive almost certainly exceeds rewriting it. Reach for Text::make(...)->asHtml() or a Nova Heading/Stack with a link unless the package's component does something you genuinely can't reproduce in a dozen lines.
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.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
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
adachsoft/php-code-style