Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

itstrueimryan's avatar

Redirect to Index Page instead of View after saving (Nova)

In Laravel Nova, if I block off access to the View pages of a Resource via a Resource Policy, I get a 403 when I create/update an instance of that resource. Is there a way to redirect to the index page of a resource after saving, as opposed to the detail page?

0 likes
5 replies
filipbaginski's avatar

Redirect to Index view after create or update:

   /**
    * Return the location to redirect the user after creation.
    *
    * @param \Laravel\Nova\Http\Requests\NovaRequest $request
    * @param \App\Nova\Resource $resource
    * @return string
    */
     public static function redirectAfterCreate(NovaRequest $request, $resource)
     {
         return '/resources/'.static::uriKey();
     }

     /**
      * Return the location to redirect the user after update.
      *
      * @param \Laravel\Nova\Http\Requests\NovaRequest $request
      * @param \App\Nova\Resource $resource
      * @return string
      */
     public static function redirectAfterUpdate(NovaRequest $request, $resource)
     {
         return '/resources/'.static::uriKey();
     }

5 likes
hellomohsinhello's avatar

create a trait and use it in resources.

<?php
namespace App\Nova;

use Laravel\Nova\Http\Requests\NovaRequest;

trait RedirectAfterAction{
    public static function redirectAfterUpdate(NovaRequest $request, $resource)
    {
        return static::redirectAfterAction();
    }

    public static function redirectAfterCreate(NovaRequest $request, $resource)
    {
        return static::redirectAfterAction();
    }

    public static function redirectAfterDelete(NovaRequest $request)
    {
        return static::redirectAfterAction();
    }

    public static function redirectAfterAction()
    {
        return '/resources/'.static::uriKey();
    }
}
3 likes

Please or to participate in this conversation.