import moons

This commit is contained in:
2021-05-30 19:03:09 +09:00
parent 120bb5edc9
commit 5a6a1a19c4
2 changed files with 18 additions and 1 deletions

View File

@@ -61,6 +61,9 @@ class ImportAllianceMoons extends Command
//Create the collection of lines for the input file.
$moons = new Collection;
AllianceMoon::truncate();
AllianceMoonOre::truncate();
//Create the file handler
$data = Storage::get('public/alliance_moons.txt');
//Split the string into separate arrays based on the line
@@ -85,6 +88,20 @@ class ImportAllianceMoons extends Command
foreach($moons as $moon) {
//If the first array is null then we are dealing with an ore
if($moon[0] == null) {
$moonInfo = $lookup->GetMoonInfo($moon[6]);
$solarName = $lookup->SolarSystemIdToName($moonInfo->system_id);
//Save the moon into the database
$newMoon = new AllianceMoon;
$newMoon->moon_id = $moonInfo->moon_id;
$newMoon->name = $moonInfo->name;
$newMoon->system_id = $moonInfo->system_id;
$newMoon->system_name = $solarName;
$newMoon->worthAmount = 0.00;
$newMoon->rented = 'No';
$newMoon->rentalAmount = 0.00;
$newMoon->save();
//Save a new entry into the database
$ore = new AllianceMoonOre;
$ore->moon_id = $moon[6];

View File

@@ -46,7 +46,7 @@ class CreateNewMoonRentalTables extends Migration
Schema::create('alliance_moon_ores', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('moon_id');
$table->string('moon_name')->nullable();
$table->string('moon_name');
$table->unsignedBigInteger('ore_type_id');
$table->string('ore_name');
$table->float('quantity');