diff --git a/app/Helpers/ClickHelper.php b/app/Helpers/ClickHelper.php index 474103f4d..e7d34e9c0 100644 --- a/app/Helpers/ClickHelper.php +++ b/app/Helpers/ClickHelper.php @@ -5,10 +5,6 @@ use Illuminate\Http\Request; class ClickHelper { - static private function getCountry($ip) { - $country_iso = geoip()->getLocation($ip)->iso_code; - return $country_iso; - } static private function getHost($url) { // Return host given URL; NULL if host is @@ -23,13 +19,13 @@ static public function recordClick(Link $link, Request $request) { * @return boolean */ - $ip = $request->ip(); + $location = geoip()->getLocation(); // Without the IP specified, it will be detected automatically and use the real user IP if website is behind CloudFlare or other Proxy (Nginx, ...) $referer = $request->server('HTTP_REFERER'); $click = new Click; $click->link_id = $link->id; - $click->ip = $ip; - $click->country = self::getCountry($ip); + $click->ip = $location->ip; + $click->country = $location->iso_code; $click->referer = $referer; $click->referer_host = ClickHelper::getHost($referer); $click->user_agent = $request->server('HTTP_USER_AGENT');