Files
phptimerboard2/app/Library/Hauling/HaulingHelper.php
2019-10-22 01:05:15 -05:00

50 lines
1.1 KiB
PHP

<?php
namespace App\Library\Hauling;
//Internal Library
use Log;
//Library
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
use Seat\Eseye\Exceptions\RequestFailedException;
//Models
use App\Models\Lookups\SolarSystem;
class HaulingHelper {
//Variables
private $esi;
//Constructor
public function __construct() {
$this->esi = new Eseye();
}
public function JumpsBetweenSystems($name1, $name2) {
//Get the systems from the database
$system1 = SolarSystem::where(['name' => $name1])->first();
$system2 = SolarSystem::where(['name' => $name2])->first();
try {
$route = $this->esi->setQueryString([
'flag' => 'secure',
])->invoke('get', '/route/{origin}/{destination}/', [
'origin' => $system1->solar_system_id,
'destination' => $system2->solar_system_id,
]);
} catch(RequestFailedException $e) {
return -1;
}
$length = sizeof($route);
return $length;
}
}
?>