|
16 | 16 | - Optionally remove the locale slug from the URL for your main language. |
17 | 17 | - [Generate localized route URL's](#generate-route-urls) in the simplest way using the `route()` helper. |
18 | 18 | - [Redirect to localized routes](#redirect-to-routes) using the `redirect()->route()` helper. |
| 19 | +- Generate localized signed route URL's |
19 | 20 | - Allow routes to be [cached](#cache-routes). |
20 | 21 | - Optionally [translate each segment](#translate-routes) in your URI's. |
21 | 22 | - **Let you work with routes without thinking too much about locales.** |
@@ -132,13 +133,17 @@ If you set `omit_url_prefix_for_locale` to `'en'` in the configuration file, the |
132 | 133 |
|
133 | 134 | You can get the URL of your named routes as usual, using the `route()` helper. |
134 | 135 |
|
| 136 | +##### 👎 The ugly way... |
| 137 | + |
135 | 138 | Normally you would have to include the locale whenever you want to generate a URL: |
136 | 139 |
|
137 | 140 | ```php |
138 | 141 | $url = route(app()->getLocale().'.admin.reports.index'); |
139 | 142 | ``` |
140 | 143 |
|
141 | | -Because that's rather ugly, this package overwrites the `route()` function and the underlying `UrlGenerator` class with an additional, optional `$locale` argument and takes care of the locale prefix for you. If you don't specify a locale, either a normal, non-localized route or a route in the current locale is returned. |
| 144 | +##### 👍 A much nicer way... |
| 145 | + |
| 146 | +Because the former is rather ugly, this package overwrites the `route()` function and the underlying `UrlGenerator` class with an additional, optional `$locale` argument and takes care of the locale prefix for you. If you don't specify a locale, either a normal, non-localized route or a route in the current locale is returned. |
142 | 147 |
|
143 | 148 | ```php |
144 | 149 | route($name, $parameters = [], $absolute = true, $locale = null) |
@@ -180,6 +185,24 @@ You can't redirect to URL's in a specific locale this way, but if you need to, y |
180 | 185 | return redirect(route('about', [], true, 'nl')); // redirects to /nl/about |
181 | 186 | ``` |
182 | 187 |
|
| 188 | +### ✍🏻 Generate Signed Route URL's |
| 189 | + |
| 190 | +Generating a [signed route URL](https://laravel.com/docs/5.8/urls#signed-urls) is just as easy. |
| 191 | + |
| 192 | +Pass it the route name, the nescessary parameters and you will get the URL for the current locale. |
| 193 | + |
| 194 | +```php |
| 195 | +$signedUrl = URL::signedRoute('reset.password', ['user' => $id], now()->addMinutes(30)); |
| 196 | +``` |
| 197 | + |
| 198 | +You can also generate a signed URL for a specific locale: |
| 199 | + |
| 200 | +```php |
| 201 | +$signedUrl = URL::signedRoute($name, $parameters, $expiration, true, 'nl'); |
| 202 | +``` |
| 203 | + |
| 204 | +Check out the [Laravel docs](https://laravel.com/docs/5.8/urls#signed-urls) for more info on signed routes. |
| 205 | + |
183 | 206 | ### 🌎 Translate Routes |
184 | 207 |
|
185 | 208 | If you want to translate the segments of your URI's, create a `routes.php` language file for each locale you [configured](#configure-supported-locales): |
@@ -285,11 +308,16 @@ php artisan route:cache |
285 | 308 | composer test |
286 | 309 | ``` |
287 | 310 |
|
288 | | -## 🔐 Security |
| 311 | +## ☕️ Credits |
| 312 | + |
| 313 | +- [Ivan Vermeyen](https://byterider.io) |
| 314 | +- [All contributors](../../contributors) |
| 315 | + |
| 316 | +## 🔓 Security |
289 | 317 |
|
290 | 318 | If you discover any security related issues, please [e-mail me](mailto:ivan@codezero.be) instead of using the issue tracker. |
291 | 319 |
|
292 | | -## 📖 Changelog |
| 320 | +## 📑 Changelog |
293 | 321 |
|
294 | 322 | See a list of important changes in the [changelog](CHANGELOG.md). |
295 | 323 |
|
|
0 commit comments