alliance moons spreadsheet conversion to services

This commit is contained in:
2020-01-31 00:07:31 -06:00
parent 2e396f4ec7
commit a52d0453bb
11 changed files with 161 additions and 13 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -0,0 +1,39 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AllianceMoons extends Model
{
// Table Name
protected $table = 'alliance_moons';
//Primary Key
public $primaryKey = 'id';
//Timestamps
public $timestamps = false;
/**
* The fillable items for each entry
*
* @var array
*/
protected $fillable = [
'Region',
'System',
'Planet',
'Moon',
'Corporation',
'FirstOre',
'FirstQuantity',
'SecondOre',
'SecondQuantity',
'ThirdOre',
'ThirdQuantity',
'FourthOre',
'FourthQuantity',
'Available',
];
}

View File

@@ -109,7 +109,7 @@ class User extends Authenticatable
}
public function getUserType() {
return User::where('user_type')->get();
return $this->user_type;
}
public function getRole() {

View File

@@ -0,0 +1,46 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAllianceMoonsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!Schema::hasTable('alliance_moons')) {
Schema::create('alliance_moons', function (Blueprint $table) {
$table->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');
}
}

View File

@@ -10,11 +10,11 @@
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdoownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Moons</a>
<div class="dropdown-menu" aria-labelledby="navbarDropDownMenuLink">
@if(auth()->user()->hasRole('User') || auth()->user()->hasRole('Renter'))
<a class="dropdown-item" href="/moons/display">Display Moons</a>
<a class="dropdown-item" href="/moons/display/rentals">Display Moons</a>
<a class="dropdown-item" href="/moons/display/form/worth">Moon Worth</a>
@endif
@if(auth()->user()->hasRole('Admin'))
<a class="dropdown-item" href="/moons/admin/display">Display Moons</a>
<a class="dropdown-item" href="/moons/admin/display/rentals">Display Moons</a>
<a class="dropdown-item" href="/moons/display/form/worth">Moon Worth</a>
<a class="dropdown-item" href="/moons/admin/updatemoon">Update Moon</a>
@endif

View File

@@ -0,0 +1,19 @@
@extends('layouts.b4')
@section('content')
<div class="container">
<h2>Moons in W4RP Space</h2>
<ul class="nav nav-pills">
<li class="active"><a data-toggle="pill" href="#6X7-JO">6X7-JO</a></li>
<li><a data-toggle="pill" href="#A-803L">A-803L</a></li>
</ul>
<div class="tab-content">
<div id="6X7-JO" class="tab-pane fade in active">
<h3>Table Goes here</h3>
</div>
<div id="A-803L" class="tab-pane fade">
<h3>Table Goes Here</h3>
</div>
</div>
</div>
@endsection

View File

@@ -125,14 +125,14 @@ Route::group(['middleware' => ['auth']], function(){
/**
* Moon Controller display pages
*/
Route::get('/moons/display', 'Moons\MoonsController@displayMoons');
Route::get('/moons/display/rentals', 'Moons\MoonsController@displayRentalMoons');
Route::get('/moons/display/form/worth', 'Moons\MoonsController@displayTotalWorthForm');
Route::post('/moons/worth', 'Moons\MoonsController@displayTotalWorth');
/**
* Moon Admin Controller display pages
*/
Route::get('/moons/admin/display', 'Moons\MoonsAdminController@displayMoonsAdmin');
Route::get('/moons/admin/display/rentals', 'Moons\MoonsAdminController@displayRentalMoonsAdmin');
Route::get('/moons/admin/updatemoon', 'Moons\MoonsAdminController@updateMoon');
Route::post('/moons/admin/updatemoon', 'Moons\MoonsAdminController@storeUpdateMoon');
Route::post('/moons/admin/display', 'Moons\MoonsAdminController@storeMoonRemoval');

View File

@@ -279,7 +279,7 @@ class ClassLoader
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
@@ -377,7 +377,7 @@ class ClassLoader
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {

View File

@@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'App\\AllianceMoons' => $baseDir . '/app/Models/Moon/AllianceMoons.php',
'App\\Console\\Commands\\CleanStaleDataCommand' => $baseDir . '/app/Console/Commands/Data/CleanStaleDataCommand.php',
'App\\Console\\Commands\\EmptyJumpBridges' => $baseDir . '/app/Console/Commands/Data/EmptyJumpBridges.php',
'App\\Console\\Commands\\FlexStructureCommand' => $baseDir . '/app/Console/Commands/Flex/FlexStructureCommand.php',
@@ -74,7 +75,7 @@ return array(
'App\\Library\\Taxes\\TaxesHelper' => $baseDir . '/app/Library/Taxes/TaxesHelper.php',
'App\\Library\\Wiki\\WikiHelper' => $baseDir . '/app/Library/Wiki/WikiHelper.php',
'App\\Models\\Admin\\AllowedLogin' => $baseDir . '/app/Models/Admin/AllowedLogin.php',
'App\\Models\\Blacklist\\BlacklistUser' => $baseDir . '/app/Models/Blacklist/BlacklistUser.php',
'App\\Models\\Blacklist\\BlacklistEntity' => $baseDir . '/app/Models/Blacklist/BlacklistEntity.php',
'App\\Models\\Config' => $baseDir . '/app/Models/Moon/Config.php',
'App\\Models\\Contracts\\AcceptedBid' => $baseDir . '/app/Models/Contracts/AcceptedBid.php',
'App\\Models\\Contracts\\Bid' => $baseDir . '/app/Models/Contracts/Bid.php',

View File

@@ -470,6 +470,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
);
public static $classMap = array (
'App\\AllianceMoons' => __DIR__ . '/../..' . '/app/Models/Moon/AllianceMoons.php',
'App\\Console\\Commands\\CleanStaleDataCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Data/CleanStaleDataCommand.php',
'App\\Console\\Commands\\EmptyJumpBridges' => __DIR__ . '/../..' . '/app/Console/Commands/Data/EmptyJumpBridges.php',
'App\\Console\\Commands\\FlexStructureCommand' => __DIR__ . '/../..' . '/app/Console/Commands/Flex/FlexStructureCommand.php',
@@ -538,7 +539,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
'App\\Library\\Taxes\\TaxesHelper' => __DIR__ . '/../..' . '/app/Library/Taxes/TaxesHelper.php',
'App\\Library\\Wiki\\WikiHelper' => __DIR__ . '/../..' . '/app/Library/Wiki/WikiHelper.php',
'App\\Models\\Admin\\AllowedLogin' => __DIR__ . '/../..' . '/app/Models/Admin/AllowedLogin.php',
'App\\Models\\Blacklist\\BlacklistUser' => __DIR__ . '/../..' . '/app/Models/Blacklist/BlacklistUser.php',
'App\\Models\\Blacklist\\BlacklistEntity' => __DIR__ . '/../..' . '/app/Models/Blacklist/BlacklistEntity.php',
'App\\Models\\Config' => __DIR__ . '/../..' . '/app/Models/Moon/Config.php',
'App\\Models\\Contracts\\AcceptedBid' => __DIR__ . '/../..' . '/app/Models/Contracts/AcceptedBid.php',
'App\\Models\\Contracts\\Bid' => __DIR__ . '/../..' . '/app/Models/Contracts/Bid.php',