简体   繁体   English

从Laravel 5.2升级到5.3后的隐式路由绑定问题

[英]Implicit route binding issue after upgraded from Laravel 5.2 to 5.3

I just upgraged my Laravel project from 5.2 to 5.3 with Shift . 我刚用Shift将我的Laravel项目从5.2升级到5.3。 After manually merging the files Shift couldn't merge I opened up a tab and went to my project. 手动合并文件后Shift无法合并我打开了一个选项卡并转到我的项目。 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. 但是当我使用slug或id上面的代码时,我只得到一个新的模型实例而不是相关的模型。 Even if I remove the sluggable trait from the model and use a ID in the route. 即使我从模型中删除了可缓慢的特征并在路径中使用了ID。 404 page doesn't display when I use an id which not exists. 当我使用不存在的id时,不显示404页面。

I'm not sure what causes the error, any ideas? 我不确定导致错误的原因是什么? Cheers. 干杯。

\\Illuminate\\Routing\\Middleware\\SubstituteBindings::class到中间件后修复。

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 如果您遇到从5.2升级的相同问题,请根据5.3版本检查您的内核文件: 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' . \\ Illuminate \\ Routing \\ Middleware \\ SubstituteBindings :: class应该包含在'web'下受保护的$ middlewareGroups中 Probably the safest option would be to copy the whole Kernel from github so you don't miss anything. 可能最安全的选择是从github复制整个内核,这样你就不会错过任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM