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

N1Prop's avatar

Nova Resource route redirect

Hello

My resource can be accessed via http://www........com/nova/resources/q-requests/1

So I'm trying to redirect to a nova resource from routes/web.php as such

return redirect()->route('nova/{view}', ['resource' => 'q-requests', 'resourceId' => $qri]);

php artisan route:list shows

| GET|HEAD | nova/{view} | | Laravel\Nova\Http\Controllers\RouterController@show | web,Laravel\Nova\Http\Middleware\Authenticate,Laravel\Nova\Http\Middleware\DispatchServingNovaEvent,Laravel\Nova\Http\Middleware\BootTools,Laravel\Nova\Http\Middleware\Authorize |

Getting ERROR: Route [nova/{view}] not defined.

Any ideas how to redirect to a nova resource?

Thank you

0 likes
9 replies
bobbybouwmann's avatar

The problem here is that Nova doesn't have a named route that's called nova.resource or something. So instead you need to use the action here

return redirect()->action('Laravel\Nova\Http\Controllers\RouterController@show', ['resource' => 'q-requests', 'resourceId' => $qri]);
N1Prop's avatar

Thank you

I did try it before, getting error

Route [Laravel\Nova\Http\Controllers\RouterController@show] not defined.

bobbybouwmann's avatar

Aah sorry about that, you need to add \ in front of it. By default, it's only looking in the App/Http/Controllers namespace

return redirect()->action('\Laravel\Nova\Http\Controllers\RouterController@show', ['resource' => 'q-requests', 'resourceId' => $qri]);
Luis Mata's avatar

Hello all, did you get to solve it?, I have. a custom tool located in /admin/custom-name and i am not able to redirect when checking for a condition in a middleware.

I have tried this ```

 return redirect()->action('\Laravel\Nova\Http\Controllers\RouterController@show', ['resource' => '/admin/custom']);
bobbybouwmann's avatar

@lmatab I think I already answered your question somewhere else, but above solution only works for resources, not custom tools.

1 like
andersb's avatar

@bobbybouwmann I could not get your solution to work. Trying to do so causes an InvalidArgumentException: Action Laravel\Nova\Http\Controllers\RouterController@show not defined. thrown on line 459 in vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php which is simply because the nova.index route is not defined (dd'ed $this->routes).

This seems to correspond to the response in this issue, and I can confirm that it does not work in Laravel Nova v3.8.2: https://github.com/laravel/nova-issues/issues/2724

Workaround solution

Implementing an invokable controller like so:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class NovaResourceRedirectController extends Controller
{
    /**
     * Redirect to a Laravel Nova Resource.
     *
     * @param  Request  $request
     * @param  string  $resource
     * @param  int|null  $id
     * @return \Illuminate\Http\RedirectResponse
     */
    public function __invoke(Request $request, string $resource, ?int $id = null)
    {
        // Nova does not have a named route (uses Vue router) so instead redirect to the router
        // @see https://laracasts.com/discuss/channels/nova/nova-resource-route-redirect?page=1
        // @see https://github.com/laravel/nova-issues/issues/2724
        return redirect()->to(config('nova.path')."/resources/{$resource}/{$id}");
    }
}

and setting up a route for this in routes/web.php

Route::get('/nova-redirect/resources/{resource}/{id?}', 'NovaResourceRedirectController')->name('nova.resource');

Make is possible to link to a Nova resource using:
```php
return redirect()->route('nova.resource', ['resource' => 'users', 'id' => 1]);

Please or to participate in this conversation.