Skip to content

Commit ff7623b

Browse files
authored
Note about default url values and implicit binding
1 parent c0c19c6 commit ff7623b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

urls.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,19 @@ 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+
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:
176+
177+
/**
178+
* The priority-sorted list of middleware.
179+
*
180+
* This forces non-global middleware to always be in the given order.
181+
*
182+
* @var array
183+
*/
184+
protected $middlewarePriority = [
185+
...
186+
\App\Http\MiddlewareSetDefaultLocaleForUrls::class,
187+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
188+
...
189+
];

0 commit comments

Comments
 (0)