intermediateLaravel
Previous
What are optional route parameters?
Next
What is the difference between implicit and explicit route model binding?
What is route model binding?
Answer
Clear, interview-ready explanation
Route model binding lets Laravel resolve a route parameter into an Eloquent model instance before the controller action or closure runs. For example, a route containing {post} can inject a Post $post argument, removing the need to manually call Post::findOrFail in every action.
By default, Laravel resolves the model by its primary key, but a model can use a custom route key such as a slug. If no matching model is found, Laravel returns a 404 response. This keeps request handlers shorter and makes resource lookup behavior consistent across the application.