Skip to content

Commit

Permalink
Added IP2Location web service.
Browse files Browse the repository at this point in the history
  • Loading branch information
ip2location authored Aug 25, 2020
1 parent 7d6da59 commit a2c8d65
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/IP2LocationLaravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@

class IP2LocationLaravel
{

public function get($ip)
public function __construct()
{
$db = new \IP2Location\Database($this->getDatabasePath(), \IP2Location\Database::FILE_IO);

$records = $db->lookup($ip, \IP2Location\Database::ALL);

return $records;
$this->db = new \IP2Location\Database($this->getDatabasePath(), \IP2Location\Database::FILE_IO);
}

private function getDatabasePath()
{
return config('ip2locationlaravel.ip2location.local.path');
}

public function get($ip)
{
$records = $this->db->lookup($ip, \IP2Location\Database::ALL);

return $records;
}

public function query($ip, $apikey, $package = 'WS1', $ssl = false, $addons = [], $language = 'en')
{

$ws = new \IP2Location\WebService($apikey, $package, $ssl);

$records = $ws->lookup($ip, $addons, $language);

return $records;
}

}

0 comments on commit a2c8d65

Please sign in to comment.