alliance moon ores

This commit is contained in:
2021-05-30 18:39:01 +09:00
parent e1ea9fe4f4
commit bc59b580b0
3 changed files with 30 additions and 21 deletions

View File

@@ -62,6 +62,9 @@ class ImportAllianceMoons extends Command
//Create the collection of lines for the input file. //Create the collection of lines for the input file.
$moons = new Collection; $moons = new Collection;
AllianceMoonOre::truncate();
AllianceMoon::truncate();
//Create the file handler //Create the file handler
$data = Storage::get('public/alliance_moons.txt'); $data = Storage::get('public/alliance_moons.txt');
//Split the string into separate arrays based on the line //Split the string into separate arrays based on the line
@@ -84,19 +87,19 @@ class ImportAllianceMoons extends Command
//Start working our way through all of the moons //Start working our way through all of the moons
//and saving the data to the database //and saving the data to the database
foreach($moons as $moon) { foreach($moons as $moon) {
//Declare variables for each instance of the foreach loop //If the first array is null then we are dealing with an ore
$moonId = null; if($moon[0] == null) {
$moonName = null; //Save a new entry into the database
$oreId = null; $ore = new AllianceMoonOre;
$oreName = null; $ore->moon_id = $moon[6];
$oreQuantity = null; $ore->moon_name = null;
$systemId = null; $ore->ore_type_id = $moon[3];
$systemname = null; $ore->ore_name = $moon[1];
$ore->quantity = $moon[2];
var_dump($moon); $ore->solar_system_id = $moon[4];
$ore->planet_id = $moon[5];
$ore->save();
}
} }
dd();
} }
} }

View File

@@ -31,5 +31,8 @@ class AllianceMoonOre extends Model
'moon_name', 'moon_name',
'ore_type_id', 'ore_type_id',
'ore_name', 'ore_name',
'quantity',
'solar_system_id',
'planet_id',
]; ];
} }

View File

@@ -31,15 +31,15 @@ class CreateNewMoonRentalTables extends Migration
Schema::create('alliance_moons', function (Blueprint $table) { Schema::create('alliance_moons', function (Blueprint $table) {
$table->id(); $table->id();
$table->unsignedBigInteger('moon_id'); $table->unsignedBigInteger('moon_id');
$table->string('name'); $table->string('name')->default('Not Assigned');
$table->unsignedBigInteger('system_id'); $table->unsignedBigInteger('system_id');
$table->string('system_name'); $table->string('system_name')->default('Not Assigned');
$table->decimal('worth_amount'); $table->decimal('worth_amount')->default(0.00);
$table->enum('rented', [ $table->enum('rented', [
'No', 'No',
'Yes', 'Yes',
]); ])->default('No');
$table->decimal('rental_amount'); $table->decimal('rental_amount')->default(0.00);
$table->timestamps(); $table->timestamps();
}); });
} }
@@ -48,9 +48,12 @@ class CreateNewMoonRentalTables extends Migration
Schema::create('alliance_moons', function (Blueprint $table) { Schema::create('alliance_moons', function (Blueprint $table) {
$table->id(); $table->id();
$table->unsignedBigInteger('moon_id'); $table->unsignedBigInteger('moon_id');
$table->string('moon_name'); $table->string('moon_name')->default('Not Assigned');
$table->unsignedBigInteger('ore_type_id'); $table->unsignedBigInteger('ore_type_id');
$table->string('ore_name'); $table->string('ore_name');
$table->float('quantity');
$table->unsignedBigInteger('solar_system_id');
$table->unsignedBigInteger('planet_id');
}); });
} }
@@ -58,8 +61,8 @@ class CreateNewMoonRentalTables extends Migration
Schema::create('alliance_moon_rentals', function (Blueprint $table) { Schema::create('alliance_moon_rentals', function (Blueprint $table) {
$table->id(); $table->id();
$table->unsignedBigInteger('moon_id'); $table->unsignedBigInteger('moon_id');
$table->string('moon_name'); $table->string('moon_name')->default('Not Assigned');
$table->decimal('rental_amount', 20, 2); $table->decimal('rental_amount', 20, 2)->default(0.00);
$table->date('rental_start')->nullable(); $table->date('rental_start')->nullable();
$table->date('rental_end')->nullable(); $table->date('rental_end')->nullable();
$table->date('next_billing_date')->nullable(); $table->date('next_billing_date')->nullable();