models/Country.php
public static function getFromIp($ipAddress)
    {
        try {
            $body = (string) Http::get('http://ip2c.org/?ip='.$ipAddress);

            if (substr($body, 0, 1) === '1') {
                $code = explode(';', $body)[1];
                return static::where('code', $code)->first();
            }
        }
        catch (Exception $e) {}
    }
public static function getFromIp($ipAddress)
    {
        try {
            $body = (string) Http::get('http://ip2c.org/?ip='.$ipAddress);

            if (substr($body, 0, 1) === '1') {
                $code = explode(';', $body)[1];
                return static::where('code', $code)->first();
            }
        }
        catch (Exception $e) {}
    }
public static function getFromIp ( $ ipAddress ) { try { $ body = ( string ) Http :: get ( 'http://ip2c.org/?ip=' . $ ipAddress ) ; if ( substr ( $ body , 0 , 1 ) === '1' ) { $ code = explode ( ';' , $ body ) [ 1 ] ; return static :: where ( 'code' , $ code ) -> first ( ) ; } } catch ( Exception $ e ) { } }
Attempts to find a country from the IP address.
@param string $ipAddress
@return self
Attempts to find a country from the IP address .