2 years ago

Route Model Binding with 2 models?

Posted 2 years ago by andreasbakir

Hello Laravel Community :)

So I have this following problem I am trying to resolve for a couple of hours, I can't get my head around it.

I have 2 Models:

Blog and Article

And i have the following routes for them:

Route::get('{blog}', '[email protected]';
Route::get('{article}', '[email protected]';

Trying to fetch a blog by it's id is working fine but trying to fetch an article I get a Model Not Found exception.

This is happening because of the order of the routes, if I switch them I will be able to find an article but nog a blog.

I already searched for a similar kind of problem and everything refers to editing the RouteServiceProvider, but I still can't get it to work. (Or maybe there has been some code change since the posts were pretty old, I am working atm with Laravel 5.4.x)

Please sign in or create an account to participate in this conversation.