Resource Controllers naming

In Resource Controllers, in routes/web.php you can specify ->names() parameter, so the URL prefix and the route name prefix may be different.

This will generate URLs like /p, /p/{id}, /p/{id}/edit etc. But you would call them:

  • route('products.index)
  • route('products.create)
  • etc
1Route::resource('p', \App\Http\Controllers\ProductController::class)->names('products');

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord