preparing to add console commands and a schedule
This commit is contained in:
42
app/Console/Commands/corpJournal.php
Normal file
42
app/Console/Commands/corpJournal.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class corpJournal extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:corpjournal';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Grabs the corporation journals and deposit in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/getCorps.php
Normal file
42
app/Console/Commands/getCorps.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class getCorps extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:getCorps';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Get corporations in alliance and store in db.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
42
app/Console/Commands/sendmail.php
Normal file
42
app/Console/Commands/sendmail.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class sendMail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'services:sendmail';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send mail to a character';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
Commands\corpJournal::class,
|
||||
Commands\getCorps::class,
|
||||
Commands\sendMail::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -24,6 +26,8 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command(corpJournal)->everyFifteenMinutes();
|
||||
// $schedule->command(getCorps)->daily();
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
@@ -30,4 +30,8 @@ class FinancesController extends Controller
|
||||
dd($journals);
|
||||
return $journals;
|
||||
}
|
||||
|
||||
public function displayTaxes() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ class FleetsController extends Controller
|
||||
public function registerFleet(Request $request) {
|
||||
//Register a new instance of the fleet class
|
||||
$fleet = new Fleet(Auth::user()->character_id);
|
||||
//Check to see if the character registering the fleet has the correct scope
|
||||
if(!$fleet->HaveEsiScope(Auth::user()->character_id, 'esi-fleets.write_fleet.v1')) {
|
||||
$esiHelper = new Esi();
|
||||
if(!$esiHelper->HaveEsiScope) {
|
||||
return view('inc.error')->with('error', 'User does not have the write fleet scope.');
|
||||
}
|
||||
|
||||
@@ -106,9 +106,15 @@ class FleetsController extends Controller
|
||||
|
||||
//Retrieve the fleet data
|
||||
$fleet = DB::table('Fleets')->where('fleet', $fleetId)->get();
|
||||
//Add a pilot to the fleet
|
||||
/**
|
||||
* Add the pilot to the fleet
|
||||
* @var fleet[0]->character_id is the FC of the fleet to get the refresh token
|
||||
* @var charId is the character being added to the fleet
|
||||
* @var fleetId is the number of the fleet to be retrieved from the database
|
||||
*/
|
||||
$error = $newPilot->AddPilot($fleet[0]->character_id, $charId, $fleetId);
|
||||
|
||||
//If we don't have an error go back to the dashboard,
|
||||
//Otherwise, send the user to the error screen and print the error out.
|
||||
if($error === null) {
|
||||
return view('/dashboard')->with('success', 'Invite for fleet sent.');
|
||||
} else {
|
||||
@@ -124,7 +130,12 @@ class FleetsController extends Controller
|
||||
$fleet = DB::table('Fleets')->where('fleet', $fleetId)->get();
|
||||
//Search for the pilot's character id through his name
|
||||
$charId = $esiHelper->FindCharacterId($name);
|
||||
//Add the pilot to the fleet
|
||||
/**
|
||||
* Add the pilot to the fleet
|
||||
* @var fleet[0]->character_id is the FC of the fleet to get the refresh token
|
||||
* @var charId is the character being added to the fleet
|
||||
* @var fleetId is the number of the fleet to be retrieved from the database
|
||||
*/
|
||||
$error = $newPilot->AddPilot($fleet[0]->character_id, $charId, $fleetId);
|
||||
//If we don't have an error go back to the dashboard,
|
||||
//Otherwise, send the user to the error screen and print the error out.
|
||||
|
||||
@@ -22,10 +22,11 @@ class Esi {
|
||||
*
|
||||
* @return true,false
|
||||
*/
|
||||
public function CheckScope($charId, $scope) {
|
||||
public function HaveEsiScope($charId, $scope) {
|
||||
//Check for an esi scope
|
||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
||||
foreach($checks as $check) {
|
||||
if($check === $scope){
|
||||
if($check->scope === $scope) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
namespace App\Library;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Session;
|
||||
use DB;
|
||||
|
||||
use App\Models\EsiScope;
|
||||
@@ -19,9 +17,6 @@ use App\Library\Esi;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
@@ -72,7 +67,23 @@ class Finances {
|
||||
|
||||
}
|
||||
|
||||
public function CalculateMonthlyTaxes($corpId, $month, $overallTax) {
|
||||
public function CalculateMonthlyRefineryTaxees($corpId, $month, $overallTax) {
|
||||
$currentTime = Carbon::now();
|
||||
$monthWanted = $month;
|
||||
$untaxed = 0.00;
|
||||
//Get the journal entries from the database
|
||||
$entries = DB::table('CorpJournals')->where(['corporation_id' => $corpId, 'created_at' => $monthWanted, 'ref_type' => 127])->get();
|
||||
foreach($entries as $entry) {
|
||||
$untaxed += $entry->tax;
|
||||
}
|
||||
//The alliance will get 1.0 pts of the tax. We need to calculate the correct percentage and return the value
|
||||
$taxRatio = $overallTax / 1.0;
|
||||
$taxed = $untaxed / $taxRatio;
|
||||
|
||||
return $taxed;
|
||||
}
|
||||
|
||||
public function CalculateMonthlyMarketTaxes($corpId, $month, $overallTax) {
|
||||
//Convert the current time to a time / date
|
||||
$currentTime = Carbon::now();
|
||||
$monthWanted = $month;
|
||||
@@ -90,8 +101,35 @@ class Finances {
|
||||
return $taxed;
|
||||
}
|
||||
|
||||
public function SendMail($charId) {
|
||||
//
|
||||
public function SendMail($charId, $taxAmount, $subject) {
|
||||
//Retrieve the token for Amund Risalo
|
||||
$token = DB::table('EsiTokens')->where('character_id', 93738489)->get();
|
||||
$configuration = Configuration::getInstance();
|
||||
$configuration->cache = NullCache::class;
|
||||
$configuration->logfile_location = '/var/www/w4rpservices/storage/logs/eseye';
|
||||
//Create the ESI authentication container
|
||||
$config = config('esi');
|
||||
$authentication = new EsiAuthentication([
|
||||
'client_id' => $config['esi']['client_id'],
|
||||
'secret' => $config['esi']['secret'],
|
||||
'refresh_token' => $token[0]->refresh_token,
|
||||
]);
|
||||
//Create the esi class variable
|
||||
$esi = new Eseye($authentication);
|
||||
try {
|
||||
$esi->setBody([
|
||||
'body' => $body,
|
||||
'receipients' => [
|
||||
'recipient_id'=> $charId,
|
||||
'recipient_type' => 'character',
|
||||
],
|
||||
'subject' => $subject,
|
||||
])->invoke('post', '/characters/{character_id}/mail/', [
|
||||
'character_id' => 93738489,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
}
|
||||
|
||||
public function GetWalletJournal($division, $charId) {
|
||||
|
||||
@@ -106,11 +106,12 @@ class Fleet {
|
||||
|
||||
try {
|
||||
//Setup the body of the esi message and perform the call
|
||||
$esi->setBody(['character_id' => $charId,
|
||||
'role' => 'squad_member',
|
||||
])->invoke('post', '/fleets/{fleet_id}/members/', [
|
||||
'fleet_id' => $fleetId,
|
||||
]);
|
||||
$esi->setBody([
|
||||
'character_id' => $charId,
|
||||
'role' => 'squad_member',
|
||||
])->invoke('post', '/fleets/{fleet_id}/members/', [
|
||||
'fleet_id' => $fleetId,
|
||||
]);
|
||||
} catch(\Seat\Eseye\Exceptions\RequestFailedException $e) {
|
||||
return $e->getEsiResponse();
|
||||
}
|
||||
@@ -121,18 +122,6 @@ class Fleet {
|
||||
public function RenderFleetDisplay() {
|
||||
//
|
||||
}
|
||||
|
||||
public function HaveEsiScope($charId, $scope) {
|
||||
//Check for an esi scope
|
||||
$checks = DB::table('EsiScopes')->where('character_id', $charId)->get();
|
||||
foreach($checks as $check) {
|
||||
if($check->scope === $scope) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
27
app/Models/AllianceCorp.php
Normal file
27
app/Models/AllianceCorp.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceCorp extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
protected $table = 'AllianceCorps';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'corporation_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateAllianceCorps extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if(!Schema::hasTable('AllianceCorps')) {
|
||||
Schema::create('AllianceCorps', function(Blueprint $table) {
|
||||
$table->integer('corporation_id')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('AllianceCorps');
|
||||
}
|
||||
}
|
||||
4
vendor/composer/autoload_classmap.php
vendored
4
vendor/composer/autoload_classmap.php
vendored
@@ -6,7 +6,11 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'App\\Console\\Commands\\corpJournal' => $baseDir . '/app/Console/Commands/corpJournal.php',
|
||||
'App\\Console\\Commands\\getCorps' => $baseDir . '/app/Console/Commands/getCorps.php',
|
||||
'App\\Console\\Commands\\sendMail' => $baseDir . '/app/Console/Commands/sendmail.php',
|
||||
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
|
||||
'App\\CorpJournal' => $baseDir . '/app/Models/CorpJournal.php',
|
||||
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
|
||||
'App\\Http\\Controllers\\AdminController' => $baseDir . '/app/Http/Controllers/AdminController.php',
|
||||
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
|
||||
|
||||
4
vendor/composer/autoload_static.php
vendored
4
vendor/composer/autoload_static.php
vendored
@@ -401,7 +401,11 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'App\\Console\\Commands\\corpJournal' => __DIR__ . '/../..' . '/app/Console/Commands/corpJournal.php',
|
||||
'App\\Console\\Commands\\getCorps' => __DIR__ . '/../..' . '/app/Console/Commands/getCorps.php',
|
||||
'App\\Console\\Commands\\sendMail' => __DIR__ . '/../..' . '/app/Console/Commands/sendmail.php',
|
||||
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
|
||||
'App\\CorpJournal' => __DIR__ . '/../..' . '/app/Models/CorpJournal.php',
|
||||
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
|
||||
'App\\Http\\Controllers\\AdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/AdminController.php',
|
||||
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
|
||||
|
||||
Reference in New Issue
Block a user