Skip to content

Commit 93d8977

Browse files
committed
added tip #351
1 parent 2601606 commit 93d8977

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Currently, there are over 300 tips categorized as follows:
1313
- πŸ› οΈ [Helpers Tips](./tips/helpers.md) (65 tips)
1414
- πŸ§ͺ [Testing Tips](./tips/testing.md) (29 tips)
1515
- πŸ’» [Artisan & Console Command Tips](./tips/console.md) (26 tips)
16-
- πŸ”„ [Routing & Request Tips](./tips/routing.md) (22 tips)
16+
- πŸ”„ [Routing & Request Tips](./tips/routing.md) (23 tips)
1717
- πŸ“Š [Laravel Collections Tips](./tips/collections.md) (17 tips)
1818
- βœ… [Validation Tips](./tips/validation.md) (19 tips)
1919
- 🌐 [API & HTTP Client Tips](./tips/api-and-http-client.md) (14 tips)

β€Žtips/routing.mdβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Force HTTPS for URLs](#laravel-tip--force-https-for-urls-️)
2323
- [The New "RouteParameter" Attribute](#laravel-tip--the-new-routeparameter-attribute-️)
2424
- [Disable Scope Bindings](#laravel-tip--disable-scope-bindings-️)
25+
- [Detect User Language](#laravel-tip--detect-user-language-️)
2526

2627
## Laravel Tip πŸ’‘: Model Binding in Form Requests ([⬆️](#routing--requests-tips-cd-))
2728

@@ -406,3 +407,14 @@ Route::get('stores/{seller}/{category:slug}', ShowStoreComponent::class)
406407
->name('stores.show')
407408
->withoutScopeBindings();
408409
```
410+
411+
## Laravel Tip πŸ’‘: Detect User Language ([⬆️](#routing--requests-tips-cd-))
412+
413+
Laravel uses Symfony's HttpFoundation component, which comes with some nice goodies. If you are working with localization and need to detect the user's preferred language, you can just call "getPreferredLanguage" πŸš€
414+
415+
```php
416+
<?php
417+
418+
// Get the user's preferred language πŸ”₯
419+
$locale = request()->getPreferredLanguage(); // en_GB
420+
```

0 commit comments

Comments
Β (0)