Skip to content

Commit 6f77b1c

Browse files
committed
formatting
1 parent ff7623b commit 6f77b1c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

urls.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ It is cumbersome to always pass the `locale` every time you call the `route` hel
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.
174174

175-
One thing to note with setting url defaults is that these can conflict with the implicit model bindings. To solve this, you need to [prioritize your middleware](https://laravel.com/docs/{{version}}/middleware#sorting-middleware) before the `SubstituteBindings` middleware that ships with Laravel:
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:
176180

177181
/**
178182
* The priority-sorted list of middleware.
@@ -182,8 +186,8 @@ One thing to note with setting url defaults is that these can conflict with the
182186
* @var array
183187
*/
184188
protected $middlewarePriority = [
185-
...
186-
\App\Http\MiddlewareSetDefaultLocaleForUrls::class,
187-
\Illuminate\Routing\Middleware\SubstituteBindings::class,
188-
...
189+
// ...
190+
\App\Http\MiddlewareSetDefaultLocaleForUrls::class,
191+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
192+
// ...
189193
];

0 commit comments

Comments
 (0)