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

Emokores's avatar

Routes not working - Inertia with React

I have a set of routes in my web.php file:


Route::name('resources.')->group(function () {
        //* Customers' routes
        Route::controller(CustomersController::class)->group(function () {
            Route::get('/customers', 'index');
            Route::get('/customers.create', 'create');
            Route::get('/customers.{customer}.edit', 'edit');
            Route::delete('/customers.{customer}.destroy', 'destroy');
        });
});

But I keep getting this error in my console Uncaught Error: Ziggy error: route 'resources.customers.index' is not in the route list.. Indeed, when I check with console.log(Ziggy.routes) it doesn't exist, and I don't know why. In my frontend Authenticated.js file, I have a link with the route route('resources.customers.index'). I don't know what I'm doing wrong.

0 likes
10 replies
Sinnbeck's avatar

Give your routes names

Route::get('/customers', 'index')->name('customers.index')';

Or use a resource instead of individual routes

Route::resource('/customers');
Emokores's avatar

@Sinnbeck When I use a resource, it gives me the error Too few arguments to function Illuminate\Routing\Router::resource(), 1 passed in /home/.../vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 337 and at least 2 expected. And, adding the name('customers.index') also doesn't work either.

Sinnbeck's avatar

@Emokores hmm maybe ressources doesn't work with controller routes. Haven't had a chance to test them yet

Anyways. Use route:list to see all available routes

Sinnbeck's avatar

Also be sure that you added the helper to the app.blade.php file

@routes 
Emokores's avatar

@Sinnbeck I actually did. My routes were working until I changed to Route::controller() group. In the route:list command, I get customers.index, customers.create instead of resources.customers.index. How do I make use of the Route::name('resources.') group?

Sinnbeck's avatar

@Emokores so it ignores the group? That sounds like a bug. I will let someone who have used the new controller routes answer as I haven't used them yet.

For now you can just do this to get it working

Route::name('resources.')->group(function () {
        //* Customers' routes
        Route::resource('/customers', CustomersController::class );
});
Emokores's avatar

@Sinnbeck It's alright. Thanks so much for the help. I'll switch back for now. Could be a bug.

Emokores's avatar
Emokores
OP
Best Answer
Level 2

@Sinnbeck I figured it out. The problem was mine. This is what I came up with:

Route::name('resources.')->group(function () {
        
        //* Customers' routes
        Route::controller(CustomersController::class)->group(function () {
            Route::get('/customers', 'index')->name('customers.index');
            Route::get('/customers.create', 'create')->name('customers.create');
            Route::get('/customers.{customer}.edit', 'edit')->name('customers.edit');
            Route::delete('/customers.{customer}.destroy', 'destroy')->name('customers.destroy');
        });

    });

Before, I had included a slash in the ->name('/customers.index') route and I did not see clearly that in route::list it gave me resources./customers.index'. So Ziggy wasn't identifying the route resources.cusomers.index that I specified.

Just see how a small issue can cause hours of headache. haha!

Please or to participate in this conversation.