#Problem with Route Model Binding, 404 NOT FOUND

13 messages · Page 1 of 1 (latest)

pulsar mountain
#

Hi, I have a problem with one route:
Route::get("/catalogo/{category:name}/{serie:name}", [ProductController::class, "index"])->name("products.show");
I got 404 NOT FOUND,

but if I change to:
Route::get("/catalogo/{category:name}/{serie}", [ProductController::class, "index"])->name("products.show");
It works.

My controller code:
`public function index(Category $category, Serie $serie)
{
dd("it's working");

    return view("product");
}`

I also have in my table "series" a column "name", please help, thanks.

burnt berry
#

Why would you use name for url? Either use id or slug

pulsar mountain
burnt berry
#

still using name is a bad idea

river flame
#

You don’t need to change the route key name when using model binding

#

Just pass it in that way from the link.

route(‘products.show’ , [‘category’ => $category->name, ‘serie’ => $serie->name]

keen reef
river flame
#

Either way, he doesn’t need to override the route key at all using model binding

keen reef
#

I see

burnt berry
#

for url everyone is using slug

#

generate it from name and use it

#

the are a lot of packages for that