From a52d0453bbd4eaa323ba547db314e9a12df647ca Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Fri, 31 Jan 2020 00:07:31 -0600 Subject: [PATCH] alliance moons spreadsheet conversion to services --- .../Moons/MoonsAdminController.php | 2 +- .../Controllers/Moons/MoonsController.php | 48 +++++++++++++++++-- app/Models/Moon/AllianceMoons.php | 39 +++++++++++++++ app/Models/User/User.php | 2 +- ..._31_035653_create_alliance_moons_table.php | 46 ++++++++++++++++++ resources/views/layouts/navbar.blade.php | 4 +- resources/views/moons/user/allmoons.blade.php | 19 ++++++++ routes/web.php | 4 +- vendor/composer/ClassLoader.php | 4 +- vendor/composer/autoload_classmap.php | 3 +- vendor/composer/autoload_static.php | 3 +- 11 files changed, 161 insertions(+), 13 deletions(-) create mode 100644 app/Models/Moon/AllianceMoons.php create mode 100644 database/migrations/2020_01_31_035653_create_alliance_moons_table.php create mode 100644 resources/views/moons/user/allmoons.blade.php diff --git a/app/Http/Controllers/Moons/MoonsAdminController.php b/app/Http/Controllers/Moons/MoonsAdminController.php index c1ec5da9b..0facdcd44 100644 --- a/app/Http/Controllers/Moons/MoonsAdminController.php +++ b/app/Http/Controllers/Moons/MoonsAdminController.php @@ -31,7 +31,7 @@ class MoonsAdminController extends Controller /** * Function to display the moons to admins */ - public function displayMoonsAdmin() { + public function displayRentalMoonsAdmin() { $this->middleware('role:Admin'); $lookupHelper = new LookupHelper; diff --git a/app/Http/Controllers/Moons/MoonsController.php b/app/Http/Controllers/Moons/MoonsController.php index 6a5c1cbdc..170522c23 100644 --- a/app/Http/Controllers/Moons/MoonsController.php +++ b/app/Http/Controllers/Moons/MoonsController.php @@ -28,16 +28,58 @@ class MoonsController extends Controller } /** - * Function to display the moons and pass data to the blade template + * Function to display all alliance moons and pass data to the blade template */ public function displayMoons() { + $moons = array(); + + //Get all of the alliance moons from the database + $moonsTemp = DB::table('AllianceMoons')->orderBy('System', 'asc')->get(); + + //Get the unique systems from the database + $systems = AllianceMoons::pluck('System')->toArray(); + + foreach($systems as $system) { + foreach($moonsTemp as $moon) { + if($moonsTemp->System == $system) { + array_push($moons[$system], [ + 'Region' => $moon->Region, + 'System' => $moon->System, + 'Planet' => $moon->Planet, + 'System' => $moon->System, + 'FirstOre' => $moon->FirstOre, + 'FirstQuantity' => $moon->FirstQuantity, + 'SecondOre' => $moon->SecondOre, + 'SecondQuantity' => $moon->SecondQuantity, + 'ThirdOre' => $moon->ThirdOre, + 'ThirdQuantity' => $moon->ThirdQuantity, + 'FourthOre' => $moon->FourthOre, + 'FourthQuantity' => $moon->FourthQuantity, + 'Corporation' => $moon->Corporation, + 'Available' => $moon->Available, + ]); + } + } + + } + + dd($moons); + + return view('moons.user.allmoons')->with('moons', $moons) + ->with('systems', $systems); + } + + /** + * Function to display the moons and pass data to the blade template + */ + public function displayRentalMoons() { $rentalEnd = ''; //Get the user type from the user Auth class - $type = Auth::user()->user_type; + $type = Auth::user()->getUserType(); //Setup calls to the MoonCalc class $moonCalc = new MoonCalc(); - //get all of the moons from the database + //get all of the rental moons from the database $moons = DB::table('Moons')->orderBy('System', 'asc')->get(); //Set the rental date as last month for moons not rented $lastMonth = Carbon::now()->subMonth(); diff --git a/app/Models/Moon/AllianceMoons.php b/app/Models/Moon/AllianceMoons.php new file mode 100644 index 000000000..03747db8a --- /dev/null +++ b/app/Models/Moon/AllianceMoons.php @@ -0,0 +1,39 @@ +get(); + return $this->user_type; } public function getRole() { diff --git a/database/migrations/2020_01_31_035653_create_alliance_moons_table.php b/database/migrations/2020_01_31_035653_create_alliance_moons_table.php new file mode 100644 index 000000000..2ba14eae4 --- /dev/null +++ b/database/migrations/2020_01_31_035653_create_alliance_moons_table.php @@ -0,0 +1,46 @@ +unsignedBigInteger('id')->unique(); + $table->string('Region'); + $table->string('System'); + $table->string('Planet'); + $table->string('Moon'); + $table->string('Corporation'); + $table->string('StructureName')->default('No Name'); + $table->string('FirstOre')->default('None'); + $table->integer('FirstQuantity')->default('0'); + $table->string('SecondOre')->default('None'); + $table->integer('SecondQuantity')->default('0'); + $table->string('ThirdOre')->default('None'); + $table->integer('ThirdQuantity')->default('0'); + $table->string('FourthOre')->default('None'); + $table->integer('FourthQuantity')->default('0'); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('alliance_moons'); + } +} diff --git a/resources/views/layouts/navbar.blade.php b/resources/views/layouts/navbar.blade.php index 185ed8d01..f699db37c 100644 --- a/resources/views/layouts/navbar.blade.php +++ b/resources/views/layouts/navbar.blade.php @@ -10,11 +10,11 @@