moon rentals again
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
//Namespace
|
||||
namespace App\Console\Commands\Files;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\File;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use DB;
|
||||
|
||||
//Application Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRental\AllianceMoonOre;
|
||||
use App\Models\MoonRental\AllianceMoon;
|
||||
|
||||
class ImportAllianceMoons extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'files:import:moons';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Import moons from tab-delimited text.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$lookup = new LookupHelper;
|
||||
//Create the collection of lines for the input file.
|
||||
$lines = new Collection;
|
||||
|
||||
///universe/moons/{moon_id}/
|
||||
|
||||
//Create the file handler
|
||||
$data = Storage::get('public/alliance_moons.txt');
|
||||
//Split the string into separate arrays based on the line
|
||||
$data = preg_split("/\n/", $data);
|
||||
|
||||
var_dump($data);
|
||||
dd();
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ class Kernel extends ConsoleKernel
|
||||
Commands\MiningTaxes\ExecuteProcesssMiningTaxesPaymentsCommand::class,
|
||||
Commands\Structures\ExecuteFetchAllianceStructuresCommand::class,
|
||||
Commands\Structures\ExecuteFetchAllianceAssetsCommand::class,
|
||||
Commands\Files\ImportAllianceMoons::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,27 @@ class MiningTaxesAdminController extends Controller
|
||||
$this->middleware('role:Admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page to setup the form for corporations to rent a moon
|
||||
*/
|
||||
public function DisplayMoonRentalForm() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the details for the form for corporations renting a specific moon
|
||||
*/
|
||||
public function StoreMoonRentalForm() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a moon from being rented from a specific corporation
|
||||
*/
|
||||
public function DeleteMoonRental(Request $request) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display current unpaid invoices
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,11 @@ class MiningTaxesController extends Controller
|
||||
$this->middleware('role:User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display an invoice based on it's id
|
||||
*
|
||||
* @var $invoiceId
|
||||
*/
|
||||
public function DisplayInvoice($invoiceId) {
|
||||
$ores = array();
|
||||
$totalPrice = 0.00;
|
||||
|
||||
@@ -18,14 +18,11 @@ class MoonRentalController extends Controller
|
||||
* Display all of the available moons for rental
|
||||
*/
|
||||
public function displayMoons() {
|
||||
$moons = AllianceMoon::where([
|
||||
'rented' => 'No',
|
||||
])->get();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to request new moon structure be placed
|
||||
*/
|
||||
public function displayNewMoonRequestForm() {
|
||||
|
||||
return view('moon.rental.available.display')->with('moons', $moons);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,4 +38,11 @@ class MoonRentalController extends Controller
|
||||
public function storeMoonRentalRequest() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a mail job be added to the mail queue to resend mining bill instantly
|
||||
*/
|
||||
public function requestMoonRentalBill() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Models\Lookups\CorporationLookup;
|
||||
use App\Models\Lookups\AllianceLookup;
|
||||
use App\Models\Lookups\SolarSystem;
|
||||
use App\Models\Lookups\ItemLookup;
|
||||
use App\Models\Lookups\MoonLookup;
|
||||
|
||||
class LookupHelper {
|
||||
|
||||
@@ -252,6 +253,58 @@ class LookupHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get moon information from the database, or store it in the database if it's not found
|
||||
*/
|
||||
public function GetMoonInfo($moonId) {
|
||||
//Check our own database first
|
||||
$moon = $this->LookupMoonInfo($moonId);
|
||||
|
||||
//If no data was found in the database, then save the data, and return what is found through esi
|
||||
if( $moon == null) {
|
||||
try {
|
||||
$response = $this->esi->invoke('get', '/universe/moons/{moon_id}/', [
|
||||
'moon_id' => $moonId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get moon information in LookupHelper.");
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->SaveMoonInfo($response);
|
||||
|
||||
return $response;
|
||||
} else {
|
||||
//Return the moon info
|
||||
return $moon;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup moon info from the database
|
||||
*/
|
||||
private function LookupMoonInfo($moonId) {
|
||||
$moon = MoonLookup::where([
|
||||
'moon_id' => $moonId,
|
||||
])->first();
|
||||
|
||||
return $moon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save moon info into the lookup database
|
||||
*/
|
||||
private function SaveMoonInfo($moon) {
|
||||
$newMoon = new MoonLookup;
|
||||
$newMoon->moon_id = $moon->id;
|
||||
$newMoon->name = $moon->name;
|
||||
$newMoon->position_x = $moon->position->x;
|
||||
$newMoon->position_y = $moon->position->y;
|
||||
$newMoon->position_z = $moon->position->z;
|
||||
$newMoon->system_id = $moon->system_id;
|
||||
$newMoon->save();
|
||||
}
|
||||
|
||||
public function GetCharacterInfo($charId) {
|
||||
//Check our own database first
|
||||
$char = $this->LookupCharacter($charId, null);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Lookups;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MoonLookup extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
public $table = 'moon_lookup';
|
||||
|
||||
/**
|
||||
* Primary Key
|
||||
*/
|
||||
public $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'moon_id',
|
||||
'name',
|
||||
'position_x',
|
||||
'position_y',
|
||||
'position_z',
|
||||
'system_id',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\MoonRental;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceMoon extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
public $table = 'alliance_moons';
|
||||
|
||||
/**
|
||||
* Primary Key
|
||||
*/
|
||||
public $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'moon_id',
|
||||
'name',
|
||||
'system_id'
|
||||
'system_name',
|
||||
'worth_amount',
|
||||
'rented',
|
||||
'rental_amount',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceMoonOre extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
public $table = 'alliance_moon_ores';
|
||||
|
||||
/**
|
||||
* Primary Key
|
||||
*/
|
||||
public $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'moon_id',
|
||||
'name',
|
||||
'ore_type_id',
|
||||
'ore_name',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\MoonRental;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AllianceMoonRental extends Model
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*/
|
||||
public $table = 'alliance_moon_rentals';
|
||||
|
||||
/**
|
||||
* Primary Key
|
||||
*/
|
||||
public $primaryKey = 'id';
|
||||
|
||||
/**
|
||||
* Timestamps
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'moon_id',
|
||||
'moon_name',
|
||||
'rental_amount',
|
||||
'rental_start',
|
||||
'rental_end',
|
||||
'next_billing_date',
|
||||
'entity_id',
|
||||
'entity_name',
|
||||
'entity_type',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user