next commit
This commit is contained in:
17
.env.example
17
.env.example
@@ -30,15 +30,8 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
EVEONLINE_CLIENT=null
|
||||
EVEONLINE_CLIENT_SECRET=null
|
||||
EVEONLINE_REDIRECT=null
|
||||
EVEONLINE_USER_AGENT='United Hauling Services'
|
||||
EVEONLINE_PRIMARY_CHAR=null
|
||||
|
||||
50
app/Http/Controllers/Hauling/Hauling.php
Normal file
50
app/Http/Controllers/Hauling/Hauling.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Hauling;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Libraries
|
||||
use App\Library\Hauling\HaulingHelper;
|
||||
|
||||
//Models
|
||||
|
||||
class Hauling extends Controller
|
||||
{
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('role:Guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display form
|
||||
*/
|
||||
public function displayForm() {
|
||||
return view('hauling.display.form');
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display form results
|
||||
*/
|
||||
public function displayFormResults(Request $request) {
|
||||
$this->validate($request, [
|
||||
'name1' => 'required',
|
||||
'name2' => 'required',
|
||||
]);
|
||||
|
||||
$hHelper = new HaulingHelper;
|
||||
|
||||
$jumps = $hHelper->JumpsBetweenSystems($request->name1, $request->name2);
|
||||
|
||||
return view('hauling.display.results')->with('jumps', $jumps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller function to display quotes for pricing tables
|
||||
*/
|
||||
public function displayQuotes() {
|
||||
return view('hauling.display.quotes');
|
||||
}
|
||||
}
|
||||
26
app/Http/Middleware/RequirePermission.php
Normal file
26
app/Http/Middleware/RequirePermission.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use DB;
|
||||
use App\Models\User\UserPermission;
|
||||
|
||||
class RequirePermission
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $permission)
|
||||
{
|
||||
$perms = UserPermission::where(['character_id' => auth()->user()->character_id, 'permission'=> $permission])->get(['permission']);
|
||||
|
||||
abort_unless(auth()->check() && isset($perms[0]->permission), 403, "You don't have the correct permission to be in this area.");
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
41
app/Http/Middleware/RequireRole.php
Normal file
41
app/Http/Middleware/RequireRole.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
use App\Models\User\UserRole;
|
||||
|
||||
class RequireRole
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $role)
|
||||
{
|
||||
$confirmed = false;
|
||||
$ranking = [
|
||||
'None' => 0,
|
||||
'Guest' => 1,
|
||||
'User' => 2,
|
||||
'Admin' => 3,
|
||||
'SuperUser' => 4,
|
||||
];
|
||||
|
||||
$check = UserRole::where('character_id', auth()->user()->character_id)->get(['role']);
|
||||
|
||||
if(!isset($check[0]->role)) {
|
||||
abort(403, "You don't any roles. You don't belong here.");
|
||||
}
|
||||
|
||||
if($ranking[$check[0]->role] < $ranking[$role]) {
|
||||
abort(403, "You don't have the correct role to be in this area.");
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
178
app/Library/Esi/Esi.php
Normal file
178
app/Library/Esi/Esi.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Esi;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//Models
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Jobs\JobSendEveMail;
|
||||
use App\Models\Mail\EveMail;
|
||||
|
||||
//Seat Stuff
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
|
||||
/**
|
||||
* This class represents a few ESI helper functions for the program
|
||||
*/
|
||||
class Esi {
|
||||
/**
|
||||
* Check if a scope is in the database for a particular character
|
||||
*
|
||||
* @param charId
|
||||
* @param scope
|
||||
*
|
||||
* @return true,false
|
||||
*/
|
||||
public function HaveEsiScope($charId, $scope) {
|
||||
//Get the esi config
|
||||
$config = config('esi');
|
||||
//Check for an esi scope
|
||||
$check = EsiScope::where(['character_id' => $charId, 'scope' => $scope])->count();
|
||||
if($check == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function GetCharacterData($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function GetCharacterName($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->name;
|
||||
}
|
||||
|
||||
public function FindCharacterId($name) {
|
||||
$config = config('esi');
|
||||
//Create the esi authentication container
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
]);
|
||||
//Create the esi container
|
||||
$esi = new Eseye($authentication);
|
||||
try {
|
||||
$character = $esi->setQueryString([
|
||||
'categories' => 'character',
|
||||
'language' => 'en-us',
|
||||
'search' => $name,
|
||||
'strict' => 'true',
|
||||
])->invoke('get', '/search/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$character = json_decode($character, true);
|
||||
return $character['character'];
|
||||
}
|
||||
|
||||
public function FindCorporationId($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $character->corporation_id;
|
||||
}
|
||||
|
||||
public function FindCorporationName($charId) {
|
||||
$esi = new Eseye();
|
||||
try {
|
||||
$character = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
|
||||
$corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $character->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $corporation->name;
|
||||
}
|
||||
|
||||
public function DecodeDate($date) {
|
||||
//Find the end of the date
|
||||
$dateEnd = strpos($date, "T");
|
||||
//Split the string up into date and time
|
||||
$dateArr = str_split($date, $dateEnd);
|
||||
//Trim the T and Z from the end of the second item in the array
|
||||
$dateArr[1] = ltrim($dateArr[1], "T");
|
||||
$dateArr[1] = rtrim($dateArr[1], "Z");
|
||||
//Combine the date
|
||||
$realDate = $dateArr[0] . " " . $dateArr[1];
|
||||
//Return the combined date in the correct format
|
||||
return $realDate;
|
||||
}
|
||||
|
||||
public function GetRefreshToken($charId) {
|
||||
//Get the refresh token from the database
|
||||
$tokenCount = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->count();
|
||||
//If the token is not found, then don't return it.
|
||||
if($tokenCount == 0) {
|
||||
return null;
|
||||
}
|
||||
$token = EsiToken::where([
|
||||
'character_id' => $charId,
|
||||
])->first();
|
||||
return $token->refresh_token;
|
||||
}
|
||||
|
||||
public function SetupEsiAuthentication($token = null) {
|
||||
//Get the platform configuration
|
||||
$config = config('esi');
|
||||
//Declare some variables
|
||||
$authentication = null;
|
||||
if($token === null) {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
]);
|
||||
} else {
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['client_id'],
|
||||
'secret' => $config['secret'],
|
||||
'refresh_token' => $token,
|
||||
]);
|
||||
}
|
||||
//Setup the esi variable
|
||||
$esi = new Eseye($authentication);
|
||||
//Return the created variable
|
||||
return $esi;
|
||||
}
|
||||
}
|
||||
?>
|
||||
50
app/Library/Hauling/HaulingHelper.php
Normal file
50
app/Library/Hauling/HaulingHelper.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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])->get();
|
||||
$system2 = SolarSystem::where(['name' => $name2])->get();
|
||||
|
||||
try {
|
||||
$route = $this->esi->invoke('get', '/route/{origin}/{destination}/', [
|
||||
'route' => $system1->solar_system_id,
|
||||
'destination' => $system2->solar_system_id,
|
||||
])->setQueryString([
|
||||
'flag' => 'secure',
|
||||
])->invoke();
|
||||
} catch(RequestFailedException $e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$length = sizeof($route);
|
||||
$length += 1;
|
||||
|
||||
return $length;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
697
app/Library/Lookups/LookupHelper.php
Normal file
697
app/Library/Lookups/LookupHelper.php
Normal file
@@ -0,0 +1,697 @@
|
||||
<?php
|
||||
|
||||
namespace App\Library\Lookups;
|
||||
|
||||
//Internal Libraries
|
||||
use DB;
|
||||
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;
|
||||
use App\Library\Esi\Esi;
|
||||
|
||||
//Models
|
||||
use App\Models\Lookups\CharacterLookup;
|
||||
use App\Models\Lookups\CorporationLookup;
|
||||
use App\Models\Lookups\AllianceLookup;
|
||||
|
||||
class NewLookupHelper {
|
||||
//Variables
|
||||
private $esi;
|
||||
|
||||
//Construct
|
||||
public function __construct() {
|
||||
$this->esi = new Eseye();
|
||||
}
|
||||
|
||||
public function GetCharacterInfo($charId) {
|
||||
try {
|
||||
$character = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return null;
|
||||
}
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function CharacterIdToName($charId) {
|
||||
//Check if the character is stored in our own database first
|
||||
$char = $this->LookupCharacter($charId, null);
|
||||
//If the char is null, then we did not find the character in our own database
|
||||
if($char != null) {
|
||||
return $char->name;
|
||||
} else {
|
||||
//Get the character id from esi
|
||||
try {
|
||||
$character = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $charId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character name from /characters/{character_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($character->name)) {
|
||||
//Store the character name for the lookup table
|
||||
$this->StoreCharacterLookup(null, $character->name);
|
||||
//Return the character name to the calling function
|
||||
return $character->name;
|
||||
} else {
|
||||
//If we don't find any information return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CharacterNameToId($charName) {
|
||||
//Check if the character is stored in our own database first
|
||||
$char = $this->LookupCharacter(null, $charName);
|
||||
if($char != null) {
|
||||
return $char->character_id;
|
||||
} else {
|
||||
try {
|
||||
$response = $this->esi->setBody(array(
|
||||
$charName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get character name from /universe/ids/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
if(isset($response->characters[0]->id)) {
|
||||
$this->StoreCharacterLookup($response->characters[0]->id, null);
|
||||
|
||||
return $response->characters[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CorporationIdToName($corpId) {
|
||||
//Check if the corporation is stored in our own database first
|
||||
$corp = $this->LookupCorporation($corpId, null);
|
||||
if($corp != null) {
|
||||
return $corp->name;
|
||||
} else {
|
||||
//Try to get the corporation details from ESI
|
||||
try {
|
||||
$corporation = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
//Log the issue
|
||||
Log::warning('Failed to get corporation name from /corporations/{corporation_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
if(isset($corporation->name)) {
|
||||
//Store the corporation name for the lookup table
|
||||
$this->StoreCorporationLookup(null, $corporation->name);
|
||||
//Return the corporation name to the calling function
|
||||
return $corporation->name;
|
||||
} else {
|
||||
//If nothing is found and ESI didn't work, return null to the calling function
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function CorporationNameToId($corpName) {
|
||||
//Check if the corporation is stored in our own database first
|
||||
$corp = $this->LookupCorporation(null, $corpName);
|
||||
if($corp != null) {
|
||||
return $corp->corporation_id;
|
||||
} else {
|
||||
//Try to get the corporation details from ESI
|
||||
try {
|
||||
$corporation = $this->esi->setBody(array(
|
||||
$corpName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the corporation id from /universe/ids/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
if(isset($response->corporations[0]->id)) {
|
||||
$this->StoreCorporationLookup($response->corporations[0]->id, null);
|
||||
return $response->corporations[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function AllianceIdToName($allianceId) {
|
||||
//Check if the alliance is stored in our own database first
|
||||
$alliance = $this->LookupAlliance($allianceId, null);
|
||||
if($alliance != null) {
|
||||
return $alliance->alliance_id;
|
||||
} else {
|
||||
//Try to get the alliance details from ESI
|
||||
try {
|
||||
$alliance = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $allianceId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the alliance name from /alliances/{alliance_id}/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
if(isset($alliance->name)) {
|
||||
$this->StoreAllianceLookup(null, $alliance->name);
|
||||
return $alliance->name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function AllianceNameToId($allianceName) {
|
||||
//Check if the alliance is stored in our own database first
|
||||
$alliance = $this->LookupAlliance(null, $allianceName);
|
||||
if($alliance != null) {
|
||||
return $alliance->name;
|
||||
} else {
|
||||
//Try to get the alliance details from ESI
|
||||
try {
|
||||
$response = $this->esi->setBody(array(
|
||||
$allianceName,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::warning('Failed to get the alliance id from /universe/ids/ in lookup helper.');
|
||||
return null;
|
||||
}
|
||||
//If the data is pulled from ESI store the data, and send the data back to the calling function
|
||||
if(isset($response->alliances[0]->id)) {
|
||||
$this->StoreAllianceLookup($response->alliances[0]->id, null);
|
||||
return $response->alliances[0]->id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function LookupCharacter($id = null, $name = null) {
|
||||
//If both the id and name are null, then there is nothing to lookup
|
||||
if($id == null & $name == null) {
|
||||
return null;
|
||||
}
|
||||
$character = null;
|
||||
//If the id is null attempt to lookup the character
|
||||
if($id != null) {
|
||||
$count = CharacterLookup::where(['character_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$character = CharacterLookup::where(['character_id' => $id])->first();
|
||||
} else {
|
||||
$character = null;
|
||||
}
|
||||
} else if($name != null) {
|
||||
//If the name is not null then attemp to lookup the character
|
||||
$count = CharacterLookup::where(['name' => $name])->count();
|
||||
if($count > 0) {
|
||||
$character = CharacterLookup::where(['name' => $name])->first();
|
||||
} else {
|
||||
$character = null;
|
||||
}
|
||||
}
|
||||
//Return the character details to the calling function
|
||||
return $character;
|
||||
}
|
||||
|
||||
public function LookupCorporation($id = null, $name = null) {
|
||||
if($id == null && $name == null) {
|
||||
return null;
|
||||
}
|
||||
$corporation = null;
|
||||
//If the id is not null attempt to lookup the character
|
||||
if($id != null) {
|
||||
$count = CorporationLookup::where(['corporation_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$corporation = CorporationLookup::where(['corporation_id' => $id])->first();
|
||||
} else {
|
||||
$corporation = null;
|
||||
}
|
||||
} else if($name != null) {
|
||||
$count = CorporationLookup::where(['name' => $name])->count();
|
||||
if($count > 0) {
|
||||
$corporation = CorporationLookup::where(['name' => $name])->count();
|
||||
} else {
|
||||
$corporation = null;
|
||||
}
|
||||
}
|
||||
return $corporation;
|
||||
}
|
||||
|
||||
public function LookupAlliance($id = null, $name = null) {
|
||||
if($id == null && $name == null) {
|
||||
return null;
|
||||
}
|
||||
$alliance = null;
|
||||
if($id != null) {
|
||||
$count = AllianceLookup::where(['alliance_id' => $id])->count();
|
||||
if($count > 0) {
|
||||
$alliance = AllianceLookup::where(['alliance_id' => $id])->first();
|
||||
} else {
|
||||
$alliance = null;
|
||||
}
|
||||
} else if($name != null) {
|
||||
$count = AllianceLookup::where(['name' => $name])->count();
|
||||
if($count > 0) {
|
||||
$alliance = AllianceLookup::where(['name' => $name])->first();
|
||||
} else {
|
||||
$alliance = null;
|
||||
}
|
||||
}
|
||||
return $alliance;
|
||||
}
|
||||
|
||||
private function StoreCharacterLookup($id = null, $name = null) {
|
||||
//Declare the esi helper
|
||||
$esiHelper = new Esi;
|
||||
//If the id and name are null, just return
|
||||
if($id == null && $name == null) {
|
||||
return;
|
||||
}
|
||||
//If the id isn't null, then get the character information from the esi via the character id
|
||||
if($id != null) {
|
||||
//See if the character already exists in the lookup table
|
||||
$count = CharacterLookup::where(['character_id' => $id])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
$corpId = $this->SaveCharacter($response, $id);
|
||||
if($corpId != null) {
|
||||
//Do a recursive call for the corporation Lookup
|
||||
$this->StoreCorporationLookup($corpId, null);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
//If the name is not null attempt to add the character to the table
|
||||
if($name != null) {
|
||||
$count = CharacterLookup::where(['name' => $name])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
//Get the character id from the ESI API
|
||||
$responseName = $this->esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $responseName->characters[0]->id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
$corpId = $this->SaveCharacter($response, $responseName->characters[0]->id);
|
||||
if($corpId != null) {
|
||||
//Do a recursive call for the corporation Lookup
|
||||
$this->StoreCorporationLookup($corpId, null);
|
||||
}
|
||||
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveCharacter($response, $charId) {
|
||||
$char = new CharacterLookup;
|
||||
$char->character_id = $charId;
|
||||
if(isset($response->alliance_id)) {
|
||||
$char->alliance_id = $response->alliance_id;
|
||||
}
|
||||
if(isset($response->ancestry_id)) {
|
||||
$char->ancestry_id = $response->ancestry_id;
|
||||
}
|
||||
$char->birthday = $response->birthday;
|
||||
$char->bloodline_id = $response->bloodline_id;
|
||||
$char->corporation_id = $response->corporation_id;
|
||||
if(isset($response->description)) {
|
||||
$char->description = $response->description;
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
$char->faction_id = $response->faction_id;
|
||||
}
|
||||
$char->gender = $response->gender;
|
||||
$char->name = $response->name;
|
||||
$char->race_id = $response->race_id;
|
||||
if(isset($response->security_status)) {
|
||||
$char->security_status = $response->security_status;
|
||||
}
|
||||
if(isset($response->title)) {
|
||||
$char->title = $response->title;
|
||||
}
|
||||
$char->save();
|
||||
return $response->corporation_id;
|
||||
}
|
||||
|
||||
public function UpdateCharacters() {
|
||||
$all = CharacterLookup::all();
|
||||
foreach($all as $entry) {
|
||||
//Attempt to get the data from ESI
|
||||
try {
|
||||
$response = $esi->invoke('get', '/characters/{character_id}/', [
|
||||
'character_id' => $entry->character_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
}
|
||||
//Update the data
|
||||
if(isset($response->alliance_id)) {
|
||||
if($response->alliance_id != $entry->alliance_id) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'alliance_id' => $response->alliance_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->description)) {
|
||||
if($response->description != $entry->description) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'description' => $response->description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->security_status)) {
|
||||
if($response->security_status != $entry->security_status) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'security_status' => $response->security_status,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->title)) {
|
||||
if($response->title != $entry->title) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'title' => $response->title,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->corporation_id)) {
|
||||
if($response->corporation_id != $entry->corporation_id) {
|
||||
CharacterLookup::where([
|
||||
'character_id' => $entry->character_id,
|
||||
])->update([
|
||||
'corporation_id' => $response->corporation_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function StoreCorporationLookup($id = null, $name = null) {
|
||||
//If the id is null and the name is null, then return
|
||||
if($id == null && $name == null) {
|
||||
return;
|
||||
}
|
||||
if($id != null) {
|
||||
$count = CorporationLookup::where(['corporation_id' => $id])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
$allianceId = $this->SaveCorporation($response, $id);
|
||||
if($allianceId != null) {
|
||||
$this->StoreAllianceLookup($allianceId);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if($name != null) {
|
||||
$count = CorporationLookup::where(['name' => $name])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
//Get the corporation id from the ESI API
|
||||
$responseName = $this->esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $responseName->corporations[0]->id,
|
||||
]);
|
||||
} catch(ReqeustFailedException $e) {
|
||||
return;
|
||||
}
|
||||
$allianceId = $this->SaveCorporation($response, $responseName->corporations[0]->id);
|
||||
if($allianceId != null) {
|
||||
//Do a recursive call for the alliance lookup
|
||||
$this->StoreAllianceLookup($allianceId, null);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveCorporation($response, $corpId) {
|
||||
$corp = new CorporationLookup;
|
||||
$corp->corporation_id = $corpId;
|
||||
if(isset($response->alliance_id)) {
|
||||
$corp->alliance_id = $response->alliance_id;
|
||||
}
|
||||
$corp->ceo_id = $response->ceo_id;
|
||||
$corp->creator_id = $response->creator_id;
|
||||
if(isset($response->date_founded)) {
|
||||
$corp->date_founded = $response->date_founded;
|
||||
}
|
||||
if(isset($response->description)) {
|
||||
$corp->description = $response->description;
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
$corp->faction_id = $response->faction_id;
|
||||
}
|
||||
if(isset($response->home_station_id)) {
|
||||
$corp->home_station_id = $response->home_station_id;
|
||||
}
|
||||
$corp->member_count = $response->member_count;
|
||||
$corp->name = $response->name;
|
||||
if(isset($response->shares)) {
|
||||
$corp->shares = $response->shares;
|
||||
}
|
||||
$corp->tax_rate = $response->tax_rate;
|
||||
$corp->ticker = $response->ticker;
|
||||
if(isset($response->url)) {
|
||||
$corp->url = $response->url;
|
||||
}
|
||||
if(isset($response->war_eligible)) {
|
||||
$corp->war_eligible = $response->war_eligible;
|
||||
}
|
||||
$corp->save();
|
||||
if(isset($response->alliance_id)) {
|
||||
return $response->alliance_id;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function UpdateCorporations() {
|
||||
$all = CorporationLookup::all();
|
||||
foreach($all as $entry) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/corporations/{corporation_id}/', [
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
}
|
||||
if(isset($response->alliance_id)) {
|
||||
if($response->alliance_id != $entry->alliance_id) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'alliance_id' => $response->alliance_id,
|
||||
]);
|
||||
}
|
||||
if(isset($response->description)) {
|
||||
if($response->description != $entry->description) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'description' => $response->description,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
if($response->faction_id != $entry->faction_id) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'faction_id' => $response->faction_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->home_station_id)) {
|
||||
if($response->home_station_id != $entry->home_station_id) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'home_station_id' => $response->home_station_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->member_count)) {
|
||||
if($response->member_count != $entry->member_count) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'member_count' => $response->member_count,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->tax_rate)) {
|
||||
if($response->tax_rate != $entry->tax_rate) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'tax_rate' => $response->tax_rate,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->url)) {
|
||||
if($response->url != $entry->url) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'url' => $response->url,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->war_eligible)) {
|
||||
if($response->war_eligible != $entry->war_eligible) {
|
||||
CorporationLookup::where([
|
||||
'corporation_id' => $entry->corporation_id,
|
||||
])->update([
|
||||
'war_eligible' => $response->war_eligible,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function StoreAllianceLookup($id = null, $name = null) {
|
||||
//Check if the passed variables are null
|
||||
if($id == null && $name == null) {
|
||||
return;
|
||||
}
|
||||
//If the id isn't null then attempt to populate the table
|
||||
if($id != null) {
|
||||
//See if the alliance already exists in the table
|
||||
$count = AllianceLookup::where(['alliance_id' => $id])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
$this->SaveAlliance($response, $id);
|
||||
}
|
||||
}
|
||||
//If the name isn't null then attempt to populate the table
|
||||
if($name != null) {
|
||||
$count = AllianceLookup::where(['name' => $name])->count();
|
||||
if($count == 0) {
|
||||
try {
|
||||
$responseName = $this->esi->setBody(array(
|
||||
$name,
|
||||
))->invoke('post', '/universe/ids/');
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $responseName->alliances[0]->id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
return;
|
||||
}
|
||||
$this->SaveAlliance($response, $responseName->alliances[0]->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function SaveAlliance($response, $allianceId) {
|
||||
$alliance = new AllianceLookup;
|
||||
$alliance->alliance_id = $allianceId;
|
||||
$alliance->creator_corporation_id = $response->creator_corporation_id;
|
||||
$alliance->creator_id = $response->creator_id;
|
||||
$alliance->date_founded = $response->date_founded;
|
||||
if(isset($response->executor_corporation_id)) {
|
||||
$alliance->executor_corporation_id = $response->executor_corporation_id;
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
$alliance->faction_id = $response->faction_id;
|
||||
}
|
||||
$alliance->name = $response->name;
|
||||
$alliance->ticker = $response->ticker;
|
||||
$alliance->save();
|
||||
}
|
||||
|
||||
public function UpdateAlliances() {
|
||||
$all = AllianceLookup::all();
|
||||
|
||||
foreach($all as $entry) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/alliances/{alliance_id}/', [
|
||||
'alliance_id' => $entry->alliance_id,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
}
|
||||
if(isset($response->executor_corporation_id)) {
|
||||
if($response->executor_corporation_id != $entry->executor_corporation_id) {
|
||||
AllianceLookup::where([
|
||||
'alliance_id' => $entry->alliance_id,
|
||||
])->update([
|
||||
'executor_corporation_id' => $response->executor_corporation_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(isset($response->faction_id)) {
|
||||
if($response->faction_id != $entry->faction_id) {
|
||||
AllianceLookup::where([
|
||||
'alliance_id' => $entry->alliance_id,
|
||||
])->update([
|
||||
'faction_id' => $response->faction_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,10 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models\Admin;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllowedLogin extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
//Table Name
|
||||
public $table = 'allowed_logins';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'entity_id',
|
||||
'entity_type',
|
||||
'login_type',
|
||||
];
|
||||
}
|
||||
@@ -1,10 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models\Esi;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EsiScope extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
// Table Name
|
||||
protected $table = 'esi_scopes';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'scope',
|
||||
];
|
||||
|
||||
public function user() {
|
||||
return $this->belongsTo('App\Models\User\User', 'character_id', 'character_id');
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models\Esi;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EsiToken extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
// Table Name
|
||||
protected $table = 'esi_tokens';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
// Timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'access_token',
|
||||
'refresh_token',
|
||||
'expires_in',
|
||||
];
|
||||
public function esiscopes() {
|
||||
return $this->hasMany('App\Models\EsiScope', 'character_id', 'character_id');
|
||||
}
|
||||
}
|
||||
32
app/Models/Lookups/AllianceLookup.php
Normal file
32
app/Models/Lookups/AllianceLookup.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'alliance_lookup';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'alliance_id',
|
||||
'creator_corporation_id',
|
||||
'creator_id',
|
||||
'date_founded',
|
||||
'executor_corporation_id',
|
||||
'faction_id',
|
||||
'name',
|
||||
'ticker',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
35
app/Models/Lookups/CharacterLookup.php
Normal file
35
app/Models/Lookups/CharacterLookup.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CharacterLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'character_lookup';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'character_id',
|
||||
'alliance_id',
|
||||
'ancestry_id',
|
||||
'birthday',
|
||||
'bloodline_id',
|
||||
'corporation_id',
|
||||
'description',
|
||||
'faction_id',
|
||||
'gender',
|
||||
'name',
|
||||
'race_id',
|
||||
'security_status',
|
||||
'title',
|
||||
];
|
||||
}
|
||||
37
app/Models/Lookups/CorporationLookup.php
Normal file
37
app/Models/Lookups/CorporationLookup.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CorporationLookup extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'corporation_lookup';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
'alliance_id',
|
||||
'ceo_id',
|
||||
'creator_id',
|
||||
'date_founded',
|
||||
'description',
|
||||
'faction_id',
|
||||
'home_station_id',
|
||||
'member_count',
|
||||
'name',
|
||||
'shares',
|
||||
'tax_rate',
|
||||
'ticker',
|
||||
'url',
|
||||
'war_eligible',
|
||||
];
|
||||
}
|
||||
24
app/Models/Lookups/SolarSystem.php
Normal file
24
app/Models/Lookups/SolarSystem.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SolarSystem extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'solar_systems';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'solar_system_id',
|
||||
];
|
||||
}
|
||||
27
app/Models/Lookups/SolarSystemDistance.php
Normal file
27
app/Models/Lookups/SolarSystemDistance.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SolarSystemDistance extends Model
|
||||
{
|
||||
//Table Name
|
||||
public $table = 'solar_system_distances';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'start_id',
|
||||
'start_name',
|
||||
'end_id',
|
||||
'end_name',
|
||||
'distance',
|
||||
];
|
||||
}
|
||||
@@ -13,15 +13,110 @@ class CreateUsersTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
if(!Schema::hasTable('users')) {
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->integer('character_id')->unsigned()->unique();
|
||||
$table->string('avatar');
|
||||
$table->string('access_token')->nullable();
|
||||
$table->string('refresh_token')->nullable();
|
||||
$table->integer('inserted_at')->default(0);
|
||||
$table->integer('expires_in')->default(0);
|
||||
$table->string('owner_hash');
|
||||
$table->string('user_type')->default('Guest');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('user_roles')) {
|
||||
Schema::create('user_roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('character_id')->unsigned();
|
||||
$table->foreign('character_id')->references('character_id')->on('users');
|
||||
$table->string('role')->default('None');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('esi_tokens')) {
|
||||
Schema::create('esi_tokens', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('character_id')->unique();
|
||||
$table->foreign('character_id')->references('character_id')->on('users');
|
||||
$table->string('access_token');
|
||||
$table->string('refresh_token');
|
||||
$table->integer('expires_in');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('esi_scopes')) {
|
||||
Schema::create('esi_scopes', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('character_id');
|
||||
$table->foreign('character_id')->references('character_id')->on('users');
|
||||
$table->string('scope');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('user_permissions')) {
|
||||
Schema::create('user_permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('character_id')->unisnged();
|
||||
$table->foreign('character_id')->references('character_id')->on('users');
|
||||
$table->string('permission');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('available_user_permissions')) {
|
||||
Schema::create('available_user_permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('permission');
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('available_user_roles')) {
|
||||
Schema::create('available_user_roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('role');
|
||||
$table->string('description');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
DB::table('available_user_roles')->insert([
|
||||
'role' => 'Guest',
|
||||
'description' => 'Guest of the site.',
|
||||
]);
|
||||
|
||||
DB::table('available_user_roles')->insert([
|
||||
'role' => 'User',
|
||||
'description' => 'User with non-admin access.',
|
||||
]);
|
||||
|
||||
DB::table('available_user_roles')->insert([
|
||||
'role' => 'Admin',
|
||||
'description' => 'User with admin access.',
|
||||
]);
|
||||
|
||||
DB::table('available_user_roles')->insert([
|
||||
'role' => 'SuperUser',
|
||||
'description' => 'SuperUser',
|
||||
]);
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('allowed_logins')) {
|
||||
Schema::create('allowed_logins', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('entity_id');
|
||||
$table->string('entity_type');
|
||||
$table->string('entity_name');
|
||||
$table->string('login_type');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,5 +127,12 @@ class CreateUsersTable extends Migration
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('user_roles');
|
||||
Schema::dropIfExists('esi_tokens');
|
||||
Schema::dropIfExists('esi_scopes');
|
||||
Schema::dropIfExists('user_permissions');
|
||||
Schema::dropIfExists('available_user_permissions');
|
||||
Schema::dropIfExists('available_user_roles');
|
||||
Schema::dropIfExists('allowed_logins');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class NewLookupTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if(!Schema::hasTable('character_lookup')) {
|
||||
Schema::create('character_lookup', function (Blueprint $table) {
|
||||
$table->unsignedInteger('character_id');
|
||||
$table->unsignedInteger('alliance_id');
|
||||
$table->unsignedInteger('ancestry_id')->nullable();
|
||||
$table->string('birthday');
|
||||
$table->unsignedInteger('bloodline_id');
|
||||
$table->unsignedInteger('corporation_id');
|
||||
$table->string('description')->nullable();
|
||||
$table->unsignedInteger('faction_id')->nullable();
|
||||
$table->string('gender');
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('race_id');
|
||||
$table->float('security_status');
|
||||
$table->string('title');
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('corporation_lookup')) {
|
||||
Schema::create('corporation_lookup', function (Blueprint $table) {
|
||||
$table->unsignedInteger('corporation_id');
|
||||
$table->unsignedInteger('alliance_id')->nullable();
|
||||
$table->unsignedInteger('ceo_id');
|
||||
$table->unsignedInteger('creator_id');
|
||||
$table->string('date_founded')->nullable();
|
||||
$table->string('description')->nullable();
|
||||
$table->unsignedInteger('faction_id')->nullable();
|
||||
$table->unsignedInteger('home_station_id')->nullable();
|
||||
$table->unsignedInteger('member_count');
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('shares')->nullable();
|
||||
$table->decimal('tax_rate', 20, 2);
|
||||
$table->string('ticker');
|
||||
$table->string('url')->nullable();
|
||||
$table->boolean('war_eligible');
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('alliance_lookup')) {
|
||||
Schema::create('alliance_lookup', function (Blueprint $table) {
|
||||
$table->unsignedInteger('alliance_id');
|
||||
$table->unsignedInteger('creator_corporation_id');
|
||||
$table->unsignedInteger('creator_id');
|
||||
$table->dateTime('date_founded');
|
||||
$table->unsignedInteger('executor_corporation_id')->nullable();
|
||||
$table->unsignedInteger('faction_id')->nullable();
|
||||
$table->string('name');
|
||||
$table->string('ticker');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('character_lookup');
|
||||
Schema::dropIfExists('corporation_lookup');
|
||||
Schema::dropIfExists('alliance_lookup');
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
class CreateSolarSystemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
@@ -13,11 +13,12 @@ class CreatePasswordResetsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
if(!Schema::hasTable('solar_systems')) {
|
||||
Schema::create('solar_systems', function (Blueprint $table) {
|
||||
$table->string('name');
|
||||
$table->string('solar_system_id')->unique();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,6 +28,6 @@ class CreatePasswordResetsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
Schema::dropIfExists('solar_systems');
|
||||
}
|
||||
}
|
||||
46
database/seeds/SolarSystemSeeder.php
Normal file
46
database/seeds/SolarSystemSeeder.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use App\Models\Lookups\SolarSystem;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
|
||||
class SolarSystemSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
|
||||
$esi = new Eseye();
|
||||
|
||||
$systems = $esi->invoke('get', '/universe/systems/');
|
||||
|
||||
foreach($systems as $system) {
|
||||
try {
|
||||
$info = $esi->invoke('get', '/universe/systems/{system_id}/', [
|
||||
'system_id' => $system,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
|
||||
}
|
||||
|
||||
$count = SolarSystem::where(['system_id' => $system])->count();
|
||||
if($count == 0) {
|
||||
SolarSystem::insert([
|
||||
'name' => $info->name,
|
||||
'solar_system_id' => $system,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
0
resources/views/hauling/display/form.blade.php
Normal file
0
resources/views/hauling/display/form.blade.php
Normal file
0
resources/views/hauling/display/quotes.blade.php
Normal file
0
resources/views/hauling/display/quotes.blade.php
Normal file
0
resources/views/hauling/display/results.blade.php
Normal file
0
resources/views/hauling/display/results.blade.php
Normal file
Reference in New Issue
Block a user