0

我已将 Laravel 从5.8升级到8.0
我注意到Laravel 6 升级指南中有关URL 生成的部分,但我也注意到不同的行为,这在任何升级指南中都没有描述(或者我可能遗漏了一些东西)。

在旧版本中,我可以使用compact()将任何变量放入路由,并且它与可能的路由参数匹配,例如,如果路由是
“xyz/{user}/{article}”并且我像“route( 'xyz', compact('superAdminUser', 'theBestArticle'))" - 这已自动正确传递到路由中。

现在变量的调用必须与 web.php 中定义的参数相同。让我们以博客文章为例。

Route::get('/article/{article}', 'ArticlesController@show')->name('articles.show');

// Correct in Laravel 5.8 and not in Laravel 8
route('articles.show', compact('post'))

// Correct in Laravel 8
route('articles.show', compact('article'))

我的问题是:自从 Laravel 的哪个版本以来,这种行为发生了变化?

4

0 回答 0