我有以下问题。
当我从控制器调用getCountry时,它工作得很完美但是当我从一个工作中调用它时我得到了这个错误
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
我不知道为什么它在控制器中有效但在作业中不起作用。有什么想法吗?
<?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;
}
}
}