更新时间:2023-02-21 17:46:10
您的声音从5.2升级到了某些版本.
Sounds like you upgraded from 5.2 up to ... some version.
Laravel 5.3使用SubstitueBindings
中间件进行隐式和显式绑定,不再在中间件堆栈之前通过路由器完成
Laravel 5.3 uses the SubstitueBindings
middleware to do the implicit and explicit bindings, it is no longer done via the router before the middleware stack.
如果您升级了该中间件并且未将其添加到任何组中,则将没有路由模型绑定,因为中间件负责用绑定替换参数.
If you upgraded and did not add this middleware to any of the groups, you will not have your route model bindings as the middleware is responsible for substituting the parameter with the binding.
路由模型绑定现在已使用中间件完成.所有应用程序都应将
Illuminate\Routing\Middleware\SubstituteBindings
添加到app/Http/Kernel.php
文件中的web
中间件组中:
"Route model binding is now accomplished using middleware. All applications should add the
Illuminate\Routing\Middleware\SubstituteBindings
to yourweb
middleware group in yourapp/Http/Kernel.php
file:
\Illuminate\Routing\Middleware\SubstituteBindings::class,
您还应该在HTTP内核的$routeMiddleware
属性中注册用于绑定替换的路由中间件:
You should also register a route middleware for binding substitution in the $routeMiddleware
property of your HTTP kernel:
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
..."