I have the following problem.
When I call getCountry from a Controller it works perfect but when I call it from a job I'm getting this error
The file \"assets/geoip/GeoIP2-City.mmdb\" does not exist or is not readable. at /home/vagrant/proyectos/ghc-l5/vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php:46
I don't know why it works in Controllers but not in Jobs. Any idea?
<?php
namespace App\Helpers;
use GeoIp2\Database\Reader;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;
class SiteHelper {
public static function getCountry($ip)
{
try
{
$reader = new Reader('assets/geoip/GeoIP2-City.mmdb');
$record = $reader->city($ip);
return $record->country->isoCode;
}
catch(\Exception $e)
{
Log::error("SiteHelper -> getCountry -> ERROR al detectar IP", ['ip' => $ip, 'exception' => $e]);
throw $e;
}
}
}