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

Redirect To Index Laravel Package

invato/redirect-to-index

Laravel package that provides a simple way to redirect requests to your application's index page or route. Configure the target and middleware, then enforce a canonical entry point or handle fallback redirects with minimal setup. Lightweight and Composer-ready.

View on GitHub
Deep Wiki
Context7

Getting Started

invato/redirect-to-index is a micro-package whose entire job is to change Nova's post-create / post-update redirect target from the resource's detail page to its index (list) page. It is a trait you opt into per resource.

  1. Require it (note the repo is archived — Packagist still resolves it, but pin the version):
    composer require invato/redirect-to-index
    
  2. Open the resource you want to change, e.g. app/Nova/User.php, and add the trait:
    use Invato\RedirectToIndex\RedirectsToIndex;
    
    class User extends Resource
    {
        use RedirectsToIndex;
    }
    
  3. Create or edit a User in the Nova UI. Instead of landing on /resources/users/42, you land on /resources/users.

Look first at the package's src/ — you'll find a single trait overriding redirectAfterCreate() and redirectAfterUpdate() (the static methods on Laravel\Nova\Resource that return the redirect path). That is the whole surface area; there is no config, service provider behavior, or middleware to reason about.

First use case: rapid data-entry workflows (invoices, inventory, log entries) where an operator is creating many records in a row and the detail screen is dead weight between entries.

Implementation Patterns

Per-resource opt-in. The trait is designed to be sprinkled only where it helps. Apply it to high-volume CRUD resources and leave resources where the detail view is the natural next step (profiles, orders you immediately inspect) on Nova's default behavior.

Base resource class. The cleaner day-to-day pattern is a project-level App\Nova\Resource that extends Laravel\Nova\Resource, applies the trait once, and have every generated resource extend that. You get consistent index-redirect behavior project-wide without remembering to add a use line to each new nova:resource.

Mix with other redirect customizations. If you already override redirectAfterCreate/redirectAfterUpdate for conditional routing (e.g. redirect to a related resource), the trait will conflict — PHP will fatal on the duplicate method. Pick one: either the trait for the simple case, or hand-written overrides for the conditional case.

Pair with index filters. Redirecting to index is most useful when the index is pre-filtered to the record you just created (e.g. a CreatedBy filter or a default sort on created_at desc). Combine the trait with $filters / $defaultSort on the resource so the user sees their new record at the top of the index rather than hunting for it.

Inline actions. This trait only affects the standard create/update form submits. It does not touch Action redirects, Lens navigation, or inline-creation modals — those have their own response handling. If your workflow uses inline create, test it separately.

Gotchas and Tips

  • Archived, zero dependents. Treat it as a code snippet, not a dependency. The trait is ~10 lines; pasting it into a base resource removes a supply-chain concern and any future Laravel/Nova compatibility risk entirely.
  • Nova version coupling. The trait overrides redirectAfterCreate(NovaRequest $request, $resource) / redirectAfterUpdate(...) with specific signatures. Nova has changed these across major versions. If a Nova upgrade breaks redirects, this trait is the first place to look — a signature mismatch means the method is silently ignored (no error, just the old behavior back).
  • Silent no-op debugging. If redirects stop working, confirm (a) the trait is actually on the resource class in use, (b) you haven't also declared redirectAfterCreate in the resource (method on the class wins over the trait), and (c) no parent class also defines it. Use dd(static::redirectAfterCreate(...)) from a tinker-style test to confirm the path returned.
  • It returns a path, not a response. If a redirect ends up at the wrong URL, the issue is almost always the returned string — check it isn't doubling the uriKey or missing the /resources/ prefix.
  • No effect on delete, attach/detach, or restore — those flows have their own redirect logic in Nova and are not covered.
  • Extension point: if you need per-user or per-request behavior (e.g. redirect to index only for certain roles), skip the trait and override the two static methods directly with your own logic — the trait offers no hooks for conditional behavior.
  • Testing. A cheap regression test: hit the Nova create endpoint via Nova::actingAs() and assert a redirect to /nova/resources/{uriKey}. Worth adding if you keep the dependency, because the failure mode above is silent.
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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings