Reputation: 5082
I just upgraged my Laravel project from 5.2 to 5.3 with Shift. After manually merging the files Shift couldn't merge I opened up a tab and went to my project. And it seems that route model binding doesn't work correctly.
I use a sluggable package.
Route::get('team/{team}', function (App\Models\Team $team) {
dd($team);
});
But when I use the code above with a slug or an id, I just get a new model instance instead of the associated model. Even if I remove the sluggable trait from the model and use a ID in the route. 404 page doesn't display when I use an id which not exists.
I'm not sure what causes the error, any ideas? Cheers.
Upvotes: 4
Views: 652
Reputation: 386
If you run into the same issue upgrading from 5.2, then check your Kernel file against the 5.3 version: https://github.com/laravel/laravel/blob/5.3/app/Http/Kernel.php
\Illuminate\Routing\Middleware\SubstituteBindings::class should be included in protected $middlewareGroups under 'web'. Probably the safest option would be to copy the whole Kernel from github so you don't miss anything.
Upvotes: 1
Reputation: 5082
Fixed after adding \Illuminate\Routing\Middleware\SubstituteBindings::class
to middleware.
Upvotes: 5