station lookup tables
This commit is contained in:
@@ -30,9 +30,12 @@ class DashboardController extends Controller
|
||||
|
||||
foreach($tempContracts as $con) {
|
||||
if($con->status != 'finished') {
|
||||
dd($con->start_location_id);
|
||||
$startSystem = $lookupHelper->GetSolarSystemName($con->start_location_id);
|
||||
$endSystem = $lookupHelper->GetSolarSystemName($con->end_location_id);
|
||||
|
||||
$startStation = $lookupHelper->GetStationDetails($con->start_location_id);
|
||||
$endStation = $lookupHelper->GetStationDetails($con->end_location_id);
|
||||
|
||||
$startSystem = $lookupHelper->GetSolarSystemName($startStation->system_id);
|
||||
$endSystem = $lookupHelper->GetSolarSystemName($endStation->system_id);
|
||||
|
||||
$final = [
|
||||
'pickup' => $startSystem,
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Models\Lookups\CharacterLookup;
|
||||
use App\Models\Lookups\CorporationLookup;
|
||||
use App\Models\Lookups\AllianceLookup;
|
||||
use App\Models\Lookups\SolarSystem;
|
||||
use App\Models\Lookups\Station;
|
||||
|
||||
class LookupHelper {
|
||||
//Variables
|
||||
@@ -703,6 +704,86 @@ class LookupHelper {
|
||||
return 'N/A';
|
||||
}
|
||||
}
|
||||
|
||||
public function GetStationDetails($stationId) {
|
||||
//Check if the station is stored in the database
|
||||
$station = $this->LookupStation($stationId, null);
|
||||
|
||||
//If the station is null, then we didn't find it, and we run the esi to find it.
|
||||
if($station != null) {
|
||||
return $station;
|
||||
} else {
|
||||
try {
|
||||
$station = $this->esi->invoke('get', '/universe/stations/{station_id}/', [
|
||||
'station_id' => $stationId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get station details from /universe/stations/{station_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($station->type_id)) {
|
||||
//Store the station details for the lookup table
|
||||
$this->StoreStationLookup($station);
|
||||
//Return the details of the station
|
||||
return $station;
|
||||
} else {
|
||||
//If we didn't get any details then return null
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function LookupStation($id = null, $name = null) {
|
||||
//if both the id and name are null, then there is nothing to look up
|
||||
if($id == null && $name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//Run through the checks to try to find the station either by id first, then the name
|
||||
if($id != null) {
|
||||
$count = StationLookup::where(['station_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$station = StationLookup::where(['station_id' => $id])->get();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if( $name != null) {
|
||||
$count = StationLookup::where(['name' => $name])->count();
|
||||
if($coutn > 0) {
|
||||
$station = StationLookup::whre(['name' => $name])->get();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//Return the details of the station if they were found
|
||||
return $station;
|
||||
}
|
||||
|
||||
private function SaveStation($response) {
|
||||
$station = new StationLookup;
|
||||
$station->max_dockable_ship_volume = $response->max_dockable_ship_volume;
|
||||
$station->name = $response->name;
|
||||
$station->office_rental_cost = $response->office_rental_cost;
|
||||
if(isset($response->owner)) {
|
||||
$station->owner = $response->owner;
|
||||
}
|
||||
$station->position_x = $response->position->x;
|
||||
$station->position_y = $response->position->y;
|
||||
$station->position_z = $response->position->z;
|
||||
if(isset($response->race_id)) {
|
||||
$station->race_id = $response->race_id;
|
||||
}
|
||||
$station->reprocessing_efficiency = $response->reprocessing_efficiency;
|
||||
$station->reprocessing_stations_take = $response->reprocessing_stations_take;
|
||||
$station->services = $response->services;
|
||||
$station->station_id = $response->station_id;
|
||||
$station->system_id = $response->system_id;
|
||||
$station->type_id = $response->type_id;
|
||||
$station->save();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
38
app/Models/Lookups/StationLookup.php
Normal file
38
app/Models/Lookups/StationLookup.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class StationLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'station_lookups';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'max_dockable_ship_volume',
|
||||
'name',
|
||||
'office_rental_cost',
|
||||
'owner',
|
||||
'position_x',
|
||||
'position_y',
|
||||
'position_z',
|
||||
'race_id',
|
||||
'reprocessing_efficiency',
|
||||
'reprocessing_stations_take',
|
||||
'services',
|
||||
'station_id',
|
||||
'system_id',
|
||||
'type_id',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateStationLookupTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if(!Schema::hasTable('station_lookup')) {
|
||||
Schema::create('station_lookup', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->float('max_dockable_ship_volume');
|
||||
$table->string('name');
|
||||
$table->float('office_rental_cost');
|
||||
$table->bigInteger('owner')->nullable();
|
||||
$table->double('position_x');
|
||||
$table->double('position_y');
|
||||
$table->double('position_z');
|
||||
$table->bigInteger('race_id')->nullable();
|
||||
$table->float('reprocessing_efficiency');
|
||||
$table->float('reprocessing_stations_take');
|
||||
$table->string('services');
|
||||
$table->bigInteger('station_id');
|
||||
$table->bigInteger('system_id');
|
||||
$table->bigInteger('type_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('station_lookup');
|
||||
}
|
||||
}
|
||||
4
vendor/composer/ClassLoader.php
vendored
4
vendor/composer/ClassLoader.php
vendored
@@ -279,7 +279,7 @@ class ClassLoader
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +377,7 @@ class ClassLoader
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath.'\\';
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
|
||||
6
vendor/composer/autoload_classmap.php
vendored
6
vendor/composer/autoload_classmap.php
vendored
@@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
|
||||
return array(
|
||||
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
|
||||
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
|
||||
'App\\Http\\Controllers\\Auth\\EsiScopeController' => $baseDir . '/app/Http/Controllers/Auth/EsiScopeController.php',
|
||||
'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
|
||||
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
|
||||
'App\\Http\\Controllers\\Dashboard\\DashboardController' => $baseDir . '/app/Http/Controllers/Dashboard/DashboardController.php',
|
||||
@@ -26,7 +27,7 @@ return array(
|
||||
'App\\Library\\Contracts\\ContractHelper' => $baseDir . '/app/Library/Contracts/ContractHelper.php',
|
||||
'App\\Library\\Esi\\Esi' => $baseDir . '/app/Library/Esi/Esi.php',
|
||||
'App\\Library\\Hauling\\HaulingHelper' => $baseDir . '/app/Library/Hauling/HaulingHelper.php',
|
||||
'App\\Library\\Lookups\\NewLookupHelper' => $baseDir . '/app/Library/Lookups/LookupHelper.php',
|
||||
'App\\Library\\Lookups\\LookupHelper' => $baseDir . '/app/Library/Lookups/LookupHelper.php',
|
||||
'App\\Models\\Admin\\AllowedLogin' => $baseDir . '/app/Models/Admin/AllowedLogin.php',
|
||||
'App\\Models\\Esi\\EsiScope' => $baseDir . '/app/Models/Esi/EsiScope.php',
|
||||
'App\\Models\\Esi\\EsiToken' => $baseDir . '/app/Models/Esi/EsiToken.php',
|
||||
@@ -36,6 +37,7 @@ return array(
|
||||
'App\\Models\\Lookups\\CorporationLookup' => $baseDir . '/app/Models/Lookups/CorporationLookup.php',
|
||||
'App\\Models\\Lookups\\SolarSystem' => $baseDir . '/app/Models/Lookups/SolarSystem.php',
|
||||
'App\\Models\\User\\AvailableUserPermission' => $baseDir . '/app/Models/User/AvailableUserPermission.php',
|
||||
'App\\Models\\User\\User' => $baseDir . '/app/Models/User/User.php',
|
||||
'App\\Models\\User\\UserPermission' => $baseDir . '/app/Models/User/UserPermission.php',
|
||||
'App\\Models\\User\\UserRole' => $baseDir . '/app/Models/User/UserRole.php',
|
||||
'App\\Providers\\AppServiceProvider' => $baseDir . '/app/Providers/AppServiceProvider.php',
|
||||
@@ -47,7 +49,7 @@ return array(
|
||||
'App\\Providers\\HorizonServiceProvider' => $baseDir . '/app/Providers/HorizonServiceProvider.php',
|
||||
'App\\Providers\\RouteServiceProvider' => $baseDir . '/app/Providers/RouteServiceProvider.php',
|
||||
'App\\SolarSystemDistance' => $baseDir . '/app/Models/Lookups/SolarSystemDistance.php',
|
||||
'App\\User' => $baseDir . '/app/Models/User/User.php',
|
||||
'App\\Traits\\EveOAuth' => $baseDir . '/app/Traits/EveOAuth.php',
|
||||
'Barryvdh\\Debugbar\\Console\\ClearCommand' => $vendorDir . '/barryvdh/laravel-debugbar/src/Console/ClearCommand.php',
|
||||
'Barryvdh\\Debugbar\\Controllers\\AssetController' => $vendorDir . '/barryvdh/laravel-debugbar/src/Controllers/AssetController.php',
|
||||
'Barryvdh\\Debugbar\\Controllers\\BaseController' => $vendorDir . '/barryvdh/laravel-debugbar/src/Controllers/BaseController.php',
|
||||
|
||||
6
vendor/composer/autoload_static.php
vendored
6
vendor/composer/autoload_static.php
vendored
@@ -488,6 +488,7 @@ class ComposerStaticInit33afb8ba5b252c3933eb137784fa7f04
|
||||
public static $classMap = array (
|
||||
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
|
||||
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
|
||||
'App\\Http\\Controllers\\Auth\\EsiScopeController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/EsiScopeController.php',
|
||||
'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php',
|
||||
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
|
||||
'App\\Http\\Controllers\\Dashboard\\DashboardController' => __DIR__ . '/../..' . '/app/Http/Controllers/Dashboard/DashboardController.php',
|
||||
@@ -506,7 +507,7 @@ class ComposerStaticInit33afb8ba5b252c3933eb137784fa7f04
|
||||
'App\\Library\\Contracts\\ContractHelper' => __DIR__ . '/../..' . '/app/Library/Contracts/ContractHelper.php',
|
||||
'App\\Library\\Esi\\Esi' => __DIR__ . '/../..' . '/app/Library/Esi/Esi.php',
|
||||
'App\\Library\\Hauling\\HaulingHelper' => __DIR__ . '/../..' . '/app/Library/Hauling/HaulingHelper.php',
|
||||
'App\\Library\\Lookups\\NewLookupHelper' => __DIR__ . '/../..' . '/app/Library/Lookups/LookupHelper.php',
|
||||
'App\\Library\\Lookups\\LookupHelper' => __DIR__ . '/../..' . '/app/Library/Lookups/LookupHelper.php',
|
||||
'App\\Models\\Admin\\AllowedLogin' => __DIR__ . '/../..' . '/app/Models/Admin/AllowedLogin.php',
|
||||
'App\\Models\\Esi\\EsiScope' => __DIR__ . '/../..' . '/app/Models/Esi/EsiScope.php',
|
||||
'App\\Models\\Esi\\EsiToken' => __DIR__ . '/../..' . '/app/Models/Esi/EsiToken.php',
|
||||
@@ -516,6 +517,7 @@ class ComposerStaticInit33afb8ba5b252c3933eb137784fa7f04
|
||||
'App\\Models\\Lookups\\CorporationLookup' => __DIR__ . '/../..' . '/app/Models/Lookups/CorporationLookup.php',
|
||||
'App\\Models\\Lookups\\SolarSystem' => __DIR__ . '/../..' . '/app/Models/Lookups/SolarSystem.php',
|
||||
'App\\Models\\User\\AvailableUserPermission' => __DIR__ . '/../..' . '/app/Models/User/AvailableUserPermission.php',
|
||||
'App\\Models\\User\\User' => __DIR__ . '/../..' . '/app/Models/User/User.php',
|
||||
'App\\Models\\User\\UserPermission' => __DIR__ . '/../..' . '/app/Models/User/UserPermission.php',
|
||||
'App\\Models\\User\\UserRole' => __DIR__ . '/../..' . '/app/Models/User/UserRole.php',
|
||||
'App\\Providers\\AppServiceProvider' => __DIR__ . '/../..' . '/app/Providers/AppServiceProvider.php',
|
||||
@@ -527,7 +529,7 @@ class ComposerStaticInit33afb8ba5b252c3933eb137784fa7f04
|
||||
'App\\Providers\\HorizonServiceProvider' => __DIR__ . '/../..' . '/app/Providers/HorizonServiceProvider.php',
|
||||
'App\\Providers\\RouteServiceProvider' => __DIR__ . '/../..' . '/app/Providers/RouteServiceProvider.php',
|
||||
'App\\SolarSystemDistance' => __DIR__ . '/../..' . '/app/Models/Lookups/SolarSystemDistance.php',
|
||||
'App\\User' => __DIR__ . '/../..' . '/app/Models/User/User.php',
|
||||
'App\\Traits\\EveOAuth' => __DIR__ . '/../..' . '/app/Traits/EveOAuth.php',
|
||||
'Barryvdh\\Debugbar\\Console\\ClearCommand' => __DIR__ . '/..' . '/barryvdh/laravel-debugbar/src/Console/ClearCommand.php',
|
||||
'Barryvdh\\Debugbar\\Controllers\\AssetController' => __DIR__ . '/..' . '/barryvdh/laravel-debugbar/src/Controllers/AssetController.php',
|
||||
'Barryvdh\\Debugbar\\Controllers\\BaseController' => __DIR__ . '/..' . '/barryvdh/laravel-debugbar/src/Controllers/BaseController.php',
|
||||
|
||||
Reference in New Issue
Block a user