This is a quick one. I was just working on a Laravel 5.3 project. The app currently runs on Laravel 5.3 but, was upgraded from Laravel 5.1. In one of my controllers, I tried to use the route model binding and to my surprise, it didn’t work at all. I was getting a null value instead of the Model that is expected when you use route model binding. After googling for few hours and banging my head against the wall, I read through the laravel upgrade documentaion from Laravel 5.1 through to Laravel 5.3 and there it was under Upgrading to 5.3 from 5.2. Route model binding uses middleware in Laravel 5.3 and for the route model binding to work as expected:

You need to update the app/Http/Kernel.php file to add theĀ Illuminate\Routing\Middleware\SubstituteBindings to the ‘web’ middleware group:


After that, you also need to update the $routeMiddleware property of the Kernel and register the bindings middleware:

And that is it. After the above mentioned changes, the route model binding should work as expected.


Happy Coding šŸ™‚