How to set laravel custom primary key

Imagine you have an id in your table called product_id that you want to be as a primary key instead of id. In this scenario, you can set your custom primary key in your model.


Now you are able to use product_id as a primary key of the Product model.