Home > Enterprise >  Route in Laravel doesnt work on get Methode
Route in Laravel doesnt work on get Methode

Time:12-09

I have tried to create a route with GET methode and doesnt work !!! the route i would like to see on browser bar

http://*******:8000/products/categories/index

My controller

    public function index(Request $request)
{
    $categories = Category::where('parent_id', null)->orderby('name', 'asc')->get();
    return view('products.categories.allcategories', compact('categories'));
}

My View folder for catategories under products --- products -------- categories

My Route file

Route::get('products/categories', [CategoryController::class, 'index'])->name('index');

when type php artisan route:list i have my route listed but when i try to get the category page it show 404 not found :

http://********:8000/products/categories

CodePudding user response:

you should try php artisan route:cache i use that code after add new route always and it's work

CodePudding user response:

You're going to the wrong url you need to go to

localhost:8000/products/categories

The index method does not relate to the URL but the action.

  • Related