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

AnwarN's avatar

Explicit route model binding for a specific controller method

I have products. My products have a reference. Here is an example of products in my database:

  • id: 1, reference: AZERTZ
  • id: 2, reference: YYRTD

The default route model binding works very well, so I have my admin pages which shows my product (and I can edit them as well) with this kind of route: /admin/product/12

What I want is to be able to tell Laravel to only change the way it binds my Product model for a controller.

The method would be: ProductController@show

The route would be: /product/azertz, or /product/yyrtd, which would bind products #1 and #2.

How can I modify the route model binding from my controller method (and not globally)?

0 likes
2 replies

Please or to participate in this conversation.