0

I have upgrade Laravel from 5.8 to 8.0.
I've noticed the section about URL Generation in Upgrade Guide for Laravel 6, but I also noticed different behavior, which is not described in any upgrade guide (or maybe I missed something).

In older version I was able to put any variable to a route using compact() and it was matched with possible route params, for example if route was
"xyz/{user}/{article}" and I used it like "route('xyz', compact('superAdminUser', 'theBestArticle'))" - this was correctly passed into route automaticaly.

Now variables must be called the same as params defined in web.php. Let's take a basic example with blog posts.

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'))

My question is: Since what version of Laravel this behavior has changed?

VG-Electronics
  • 230
  • 2
  • 16
  • What does it matter? Just do it the documented way, and it will work in all versions. – miken32 Jan 22 '21 at 15:45
  • @miken32 I know, but I'd like to know what happens and why :) For example if someone will have such problem with it, what will I answer him? "I don't know why, but change your code this way"? I don't think you would vote for this as the best answer. – VG-Electronics Jan 22 '21 at 15:54

0 Answers0