Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
octoberapp committed Aug 9, 2023
1 parent d0a6c32 commit 06a3fc8
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions models/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,20 @@ public static function getDefault()
}

/**
* Attempts to find a country from the IP address.
* getFromIp attempts to find a country from the IP address.
* @param string $ipAddress
* @return self
* @return self|null
*/
public static function getFromIp($ipAddress)
{
try {
try {
$body = Http::get('https://api.country.is/'.$ipAddress);

$body = Http::get('https://api.country.is/'.$ipAddress);

if($body->code == 200) {
$json = json_decode($body->body);
return static::where('code', strtolower($json->country))->first();
}
}
catch (Exception $e) {}
if ($body->code === 200) {
$json = json_decode($body->body);
return static::where('code', strtolower($json->country))->first();
}
}
catch (Exception $e) {}
}
}

0 comments on commit 06a3fc8

Please sign in to comment.