mozew's avatar
Level 6

Route [categories] not defined. (View: C:\xampp\htdocs\new\shopping\resources\views\Admin\categories\index.blade.php)

I use laravel 5.8.

web.php

Route::resource('categories', 'CategoryController');

CategoryController.php

public function store(Request $request)
{
    $category = new Category();
    $category->name = $request->name;
    $category->save();
    return redirect(route('categories.index'));
}

After it save, It want go to index page but I seer this error.

Route [categories] not defined. (View: C:\xampp\htdocs\new\shopping\resources\views\Admin\categories\index.blade.php)

0 likes
1 reply
Snapey's avatar

In your view (not shown) you have a route statement, eg {{ route('categories') }} This has the error.

Show this line from the view.

run php artisan route:list and choose the name of the route you want, eg {{ route('categories.index') }} or whatever function you were trying to link to

1 like

Please or to participate in this conversation.