Hi @anwarn, you can refer to this video https://www.youtube.com/watch?v=XsHgZD7tE_o model
public function getRouteKeyName(){
return 'column_name';
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have products. My products have a reference. Here is an example of products in my database:
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)?
Please or to participate in this conversation.