finances and fleets

This commit is contained in:
2018-10-28 20:44:15 -05:00
parent 5029cabb43
commit f6db74624a
16 changed files with 351 additions and 3 deletions

View File

@@ -88,6 +88,18 @@ class LoginController extends Controller
//Search for user in the database
$authUser = User::where('character_id', $eve_user->id)->first();
if($authUser) {
User::update([
'name' => $eve_user->getName(),
'email' => null,
'avatar' => $eve_user->avatar,
'owner_hash' => $eve_user->owner_hash,
'character_id' => $eve_user->getId(),
'expires_in' => $eve_user->expiresIn,
'access_token' => $eve_user->token,
'refresh_token' => $eve_user->refreshToken,
'user_type' => $accountType,
]);
return $authUser;
} else {
//Get what type of account the user should have

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Socialite;
use Auth;
use App\User;
use App\Libary\Finances;
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
class FinancesController extends Controller
{
public function redirectToProvider() {
return Socialite::driver('eveonline')->setScopes(['publicData', 'esi-wallet.read_corporation_wallet.v1'])->redirect();
}
public function displayWallet() {
$esi = new Finances();
//Get the Journal Entries and just return them
$journals = $esi->GetMasterWalletJouranl();
return $journals;
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class FleetsController extends Controller
{
//
}

55
app/Library/Finances.php Normal file
View File

@@ -0,0 +1,55 @@
<?php
/**
* W4RP Services
* GNU Public License
*/
namespace App\Library;
use Illuminate\Http\Request;
use Session;
use DB;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
use App\User;
class Finances {
protected $refreshToken;
protected $expires;
private $esi;
public function __constrct() {
$user = DB::table('users')->where('name', 'Minerva Arbosa')->get();
$authentication = new \Seat\Eseye\Containers\EsiAuthentication([
'client_id' => env(ESI_CLIENT_ID),
'secret' => env(ESI_SECRET_KEY),
'refresh_token' => $user->refresh_token,
]);
$this->esi = new \Seat\Eseye\Eseye($authentication);
}
public function GetMarketGroups() {
$instance = new \Seat\Eseye\Eseye();
$marketGroups = $instance->invoke('get', '/markets/groups/');
}
public function GetMasterWalletJournal() {
$journal = $this->esi->invoke('get', '/corporations/98287666/wallets/1/journal/');
return $journal;
}
}
?>

17
app/Models/EsiToken.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class EsiToken extends Model
{
// Table Name
protected $table = 'EsiTokens';
//Primary Key
public $primaryKey = 'id';
// Timestamps
public $timestamps = true;
}

View File

@@ -0,0 +1,14 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class HoldingCorpJournal extends Model
{
// Table Name
protected $table = 'HoldingCorpFinancesJournal';
// Timestamps
public $timestamps = false;
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class MarketOrder extends Model
{
// Table Name
protected $table = 'MarketOrders';
// Timestamps
public $timestamps = false;
// Primary Key
public $primaryKey = 'order_id';
}

View File

@@ -13,5 +13,5 @@ class Price extends Model
public $primaryKey = 'id';
// Timestamps
public $timestamps = 'false';
public $timestamps = false;
}

17
app/Models/Structure.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Structure extends Model
{
// Table Name
protected $table = 'Structures';
// Timestamps
public $timestamps = true;
//Primary Key
public $primaryKey = 'structure_id';
}

View File

@@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMarketOrders extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('MarketOrders', function(Blueprint $table) {
$table->integer('duration');
$table->boolean('is_buy_order');
$table->date('issued');
$table->integer('location_id');
$table->integer('min_volume');
$table->integer('order_id')->unique();
$table->decimal('price', 20, 2);
$table->string('range');
$table->integer('system_id');
$table->integer('volume_remain');
$table->integer('volume_total');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('MarketOrders');
}
}

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateStructures extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('Structures', function(Blueprint $table) {
$table->integer('corporation_id');
$table->date('fuel_expires');
$table->date('next_reinforce_apply');
$table->integer('next_reinforce_hour');
$table->integer('next_reinforce_weekday');
$table->integer('profile_id');
$table->integer('reinforce_hour');
$table->integer('reinforce_weekday');
$table->data('services');
$table->string('state');
$table->date('state_timer_end');
$table->date('state_timer_start');
$table->integer('structure_id')->unique();
$table->integer('system_id');
$table->integer('type_id');
$table->date('unanchors_at');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('Structures');
}
}

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateHoldingCorpFinancesJournal extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('HoldingCorpFinancesJournal', function(Blueprint $table) {
$table->integer('id')->unique();
$table->decimal('amount', 20, 2);
$table->decimal('balance', 20, 2);
$table->integer('context_id');
$table->string('context_id_type');
$table->date('date');
$table->string('description');
$table->integer('first_party_id')->nullable();
$table->string('reason')->nullabe();
$table->string('ref_type');
$table->integer('second_party_id')->nullable();
$table->decimal('tax', 20, 2)->default(0.00);
$table->integer('tax_receiver_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('HoldingcorpFinancesJournal');
}
}

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateEsiTokens extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('EsiTokens', function(Blueprint $table) {
$table->integer('id')->increments();
$table->integer('character_id');
$table->string('access_token');
$table->string('refresh_token');
$table->integer('expires_in');
$table->string('scopes');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('EsiTokens');
}
}

View File

@@ -37,3 +37,7 @@ Route::get('/wiki/changepassword', 'WikiController@displayChangePassword');
//Wiki Controller POST requests
Route::post('storeRegister', 'WikiController@storeRegister');
Route::post('changePassword', 'WikiController@changePassword');
//Finance Controller display pages
Route::get('/finances/login', 'FinancesController@redirectToProvider');
Route::get('/finances/display/wallet', 'FinancesController@displayWallet');

View File

@@ -15,6 +15,7 @@ return array(
'App\\Http\\Controllers\\Auth\\VerificationController' => $baseDir . '/app/Http/Controllers/Auth/VerificationController.php',
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\DashboardController' => $baseDir . '/app/Http/Controllers/DashboardController.php',
'App\\Http\\Controllers\\FinancesController' => $baseDir . '/app/Http/Controllers/FinancesController.php',
'App\\Http\\Controllers\\MoonsController' => $baseDir . '/app/Http/Controllers/MoonsController.php',
'App\\Http\\Controllers\\WikiController' => $baseDir . '/app/Http/Controllers/WikiController.php',
'App\\Http\\Kernel' => $baseDir . '/app/Http/Kernel.php',
@@ -25,7 +26,9 @@ return array(
'App\\Http\\Middleware\\TrimStrings' => $baseDir . '/app/Http/Middleware/TrimStrings.php',
'App\\Http\\Middleware\\TrustProxies' => $baseDir . '/app/Http/Middleware/TrustProxies.php',
'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php',
'App\\Library\\Finances' => $baseDir . '/app/Library/Finances.php',
'App\\Library\\MoonCalc' => $baseDir . '/app/Library/MoonCalc.php',
'App\\MarketOrder' => $baseDir . '/app/Models/MarketOrder.php',
'App\\Models\\Config' => $baseDir . '/app/Models/Config.php',
'App\\Models\\DokuGroupNames' => $baseDir . '/app/Models/DokuGroupNames.php',
'App\\Models\\DokuMember' => $baseDir . '/app/Models/DokuMember.php',
@@ -39,6 +42,7 @@ return array(
'App\\Providers\\BroadcastServiceProvider' => $baseDir . '/app/Providers/BroadcastServiceProvider.php',
'App\\Providers\\EventServiceProvider' => $baseDir . '/app/Providers/EventServiceProvider.php',
'App\\Providers\\RouteServiceProvider' => $baseDir . '/app/Providers/RouteServiceProvider.php',
'App\\Structure' => $baseDir . '/app/Models/Structure.php',
'App\\User' => $baseDir . '/app/User.php',
'BeyondCode\\DumpServer\\DumpServerCommand' => $vendorDir . '/beyondcode/laravel-dump-server/src/DumpServerCommand.php',
'BeyondCode\\DumpServer\\DumpServerServiceProvider' => $vendorDir . '/beyondcode/laravel-dump-server/src/DumpServerServiceProvider.php',
@@ -2769,7 +2773,6 @@ return array(
'Predis\\Transaction\\AbortedMultiExecException' => $vendorDir . '/predis/predis/src/Transaction/AbortedMultiExecException.php',
'Predis\\Transaction\\MultiExec' => $vendorDir . '/predis/predis/src/Transaction/MultiExec.php',
'Predis\\Transaction\\MultiExecState' => $vendorDir . '/predis/predis/src/Transaction/MultiExecState.php',
'PricesSeeder' => $baseDir . '/database/seeds/PricesSeeder.php',
'Prophecy\\Argument' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Argument.php',
'Prophecy\\Argument\\ArgumentsWildcard' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Argument/ArgumentsWildcard.php',
'Prophecy\\Argument\\Token\\AnyValueToken' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Argument/Token/AnyValueToken.php',

View File

@@ -410,6 +410,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Http\\Controllers\\Auth\\VerificationController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/VerificationController.php',
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\DashboardController' => __DIR__ . '/../..' . '/app/Http/Controllers/DashboardController.php',
'App\\Http\\Controllers\\FinancesController' => __DIR__ . '/../..' . '/app/Http/Controllers/FinancesController.php',
'App\\Http\\Controllers\\MoonsController' => __DIR__ . '/../..' . '/app/Http/Controllers/MoonsController.php',
'App\\Http\\Controllers\\WikiController' => __DIR__ . '/../..' . '/app/Http/Controllers/WikiController.php',
'App\\Http\\Kernel' => __DIR__ . '/../..' . '/app/Http/Kernel.php',
@@ -420,7 +421,9 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Http\\Middleware\\TrimStrings' => __DIR__ . '/../..' . '/app/Http/Middleware/TrimStrings.php',
'App\\Http\\Middleware\\TrustProxies' => __DIR__ . '/../..' . '/app/Http/Middleware/TrustProxies.php',
'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php',
'App\\Library\\Finances' => __DIR__ . '/../..' . '/app/Library/Finances.php',
'App\\Library\\MoonCalc' => __DIR__ . '/../..' . '/app/Library/MoonCalc.php',
'App\\MarketOrder' => __DIR__ . '/../..' . '/app/Models/MarketOrder.php',
'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Config.php',
'App\\Models\\DokuGroupNames' => __DIR__ . '/../..' . '/app/Models/DokuGroupNames.php',
'App\\Models\\DokuMember' => __DIR__ . '/../..' . '/app/Models/DokuMember.php',
@@ -434,6 +437,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Providers\\BroadcastServiceProvider' => __DIR__ . '/../..' . '/app/Providers/BroadcastServiceProvider.php',
'App\\Providers\\EventServiceProvider' => __DIR__ . '/../..' . '/app/Providers/EventServiceProvider.php',
'App\\Providers\\RouteServiceProvider' => __DIR__ . '/../..' . '/app/Providers/RouteServiceProvider.php',
'App\\Structure' => __DIR__ . '/../..' . '/app/Models/Structure.php',
'App\\User' => __DIR__ . '/../..' . '/app/User.php',
'BeyondCode\\DumpServer\\DumpServerCommand' => __DIR__ . '/..' . '/beyondcode/laravel-dump-server/src/DumpServerCommand.php',
'BeyondCode\\DumpServer\\DumpServerServiceProvider' => __DIR__ . '/..' . '/beyondcode/laravel-dump-server/src/DumpServerServiceProvider.php',
@@ -3164,7 +3168,6 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'Predis\\Transaction\\AbortedMultiExecException' => __DIR__ . '/..' . '/predis/predis/src/Transaction/AbortedMultiExecException.php',
'Predis\\Transaction\\MultiExec' => __DIR__ . '/..' . '/predis/predis/src/Transaction/MultiExec.php',
'Predis\\Transaction\\MultiExecState' => __DIR__ . '/..' . '/predis/predis/src/Transaction/MultiExecState.php',
'PricesSeeder' => __DIR__ . '/../..' . '/database/seeds/PricesSeeder.php',
'Prophecy\\Argument' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Argument.php',
'Prophecy\\Argument\\ArgumentsWildcard' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Argument/ArgumentsWildcard.php',
'Prophecy\\Argument\\Token\\AnyValueToken' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Argument/Token/AnyValueToken.php',