coder2
https://github.com/danielme85/laravel-geoip2
Kullandığım paket bu.
`$getIps = Ip::all();
$reader = Reader::connect();
foreach ($getIps as $ip){
$array = [];
$getLogs = DB::table("logs")
->where('attacked', '=', $ip->ipAddress)
->get();
foreach ($getLogs as $log){
try {
$result = $reader->city($log->attacker);
}
catch (\Exception $e) {
$result = new \ArrayObject();
$result->setFlags(\ArrayObject::STD_PROP_LIST|\ArrayObject::ARRAY_AS_PROPS);
$result->country = ['isoCode'=>NULL];
$result->location = ['latitude'=>NULL,'longitude'=>NULL];
}
$new = [
'country' => $result->country->isoCode,
'latitude' => $result->location->latitude,
'longitude' => $result->location->longitude
];
array_push($array, $new);
}
$map = new Map;
$map->ipAddress = $ip->ipAddress;
$map->content = json_encode($array);
$map->save();
}`
Kod bloğum ise böyle.