Skip to content

Commit 04201b9

Browse files
committed
Merge branch 'driesvints-patch-1' into 8.x
2 parents e7c4935 + 6f77b1c commit 04201b9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

urls.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,23 @@ It is cumbersome to always pass the `locale` every time you call the `route` hel
171171
}
172172

173173
Once the default value for the `locale` parameter has been set, you are no longer required to pass its value when generating URLs via the `route` helper.
174+
175+
#### URL Defaults & Middleware Priority
176+
177+
Setting URL default values can interfere with Laravel's handling of implicit model bindings. Therefore, you should [prioritize your middleware](https://laravel.com/docs/{{version}}/middleware#sorting-middleware) that set URL defaults to be executed before Laravel's own `SubstituteBindings` middleware. You can accomplish this by making sure your middleware occurs before the `SubstituteBindings` middleware within the `$middlewarePriority` property of your application's HTTP kernel.
178+
179+
The `$middlewarePriority` property is defined in the base `Illuminate\Foundation\Http\Kernel` class. You may copy its definition from that class and overwrite it in your application's HTTP kernel in order to modify it:
180+
181+
/**
182+
* The priority-sorted list of middleware.
183+
*
184+
* This forces non-global middleware to always be in the given order.
185+
*
186+
* @var array
187+
*/
188+
protected $middlewarePriority = [
189+
// ...
190+
\App\Http\MiddlewareSetDefaultLocaleForUrls::class,
191+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
192+
// ...
193+
];

0 commit comments

Comments
 (0)