composer update
This commit is contained in:
@@ -19,6 +19,10 @@ class GeoIPServiceProvider extends ServiceProvider
|
||||
$this->registerResources();
|
||||
$this->registerGeoIpCommands();
|
||||
}
|
||||
|
||||
if ($this->isLumen() === false) {
|
||||
$this->mergeConfigFrom(__DIR__ . '/../config/geoip.php', 'geoip');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,4 +76,4 @@ class GeoIPServiceProvider extends ServiceProvider
|
||||
{
|
||||
return str_contains($this->app->version(), 'Lumen') === true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
52
vendor/torann/geoip/src/Services/IPData.php
vendored
Normal file
52
vendor/torann/geoip/src/Services/IPData.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Torann\GeoIP\Services;
|
||||
|
||||
use Exception;
|
||||
use Torann\GeoIP\Support\HttpClient;
|
||||
|
||||
/**
|
||||
* Class GeoIP
|
||||
* @package Torann\GeoIP\Services
|
||||
*/
|
||||
class IPData extends AbstractService
|
||||
{
|
||||
/**
|
||||
* Http client instance.
|
||||
*
|
||||
* @var HttpClient
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* The "booting" method of the service.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->client = new HttpClient([
|
||||
'base_uri' => 'https://api.ipdata.co/',
|
||||
'query' => [
|
||||
'api-key' => $this->config('key'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @throws Exception
|
||||
*/
|
||||
public function locate($ip)
|
||||
{
|
||||
// Get data from client
|
||||
$data = $this->client->get($ip);
|
||||
|
||||
// Verify server response
|
||||
if ($this->client->getErrors() !== null || empty($data[0])) {
|
||||
throw new Exception('Request failed (' . $this->client->getErrors() . ')');
|
||||
}
|
||||
|
||||
return $this->hydrate(json_decode($data[0], true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user