Skip to content

Commit

Permalink
optimize docs for get GeoIP data in client locale
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Jul 12, 2021
1 parent a5eb193 commit 9664fc9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ class GeoIPController
{
public function index(Request $request, ReaderFactory $factory): Response
{
$locale = $request->getLocale();
$ip = $request->getClientIp();
$client_locale = $request->getLocale();
$client_ip = $request->getClientIp();
$database_name = 'default';
$fallback_locale = 'en';
$reader = $factory->create('default', [$locale, 'en' /* fallback */]);
$record = $reader->city($ip);
$reader = $factory->create($database_name, [$client_locale, $fallback_locale]);
$record = $reader->city($client_ip);
return new Response(sprintf('You are from %s?', $record->country->name));
}
Expand Down

0 comments on commit 9664fc9

Please sign in to comment.