modified how rental prices are displayed based on user, and added a section for admins to be able to see all automatically

modified user table to drop roles and scopes columns from the database
This commit is contained in:
2018-11-10 14:36:54 -06:00
parent f8885853ab
commit 70832d14e5
7 changed files with 114 additions and 4 deletions

View File

@@ -167,7 +167,6 @@ class LoginController extends Controller
'expires_in' => $eve_user->expiresIn,
'access_token' => $eve_user->token,
'user_type' => $this->GetAccountType(null, $eve_user->id),
'role' => $role,
]);
}
}

View File

@@ -19,9 +19,9 @@ class MoonsController extends Controller
}
/**
* Function to display the moons and pass data to the blade template
* Function to display the moons to admins
*/
public function displayMoons() {
public function displayMoonsAdmin() {
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//Update the prices for the moon
@@ -55,6 +55,53 @@ class MoonsController extends Controller
$html .= '</tr>';
}
return view('moons.adminmoon')->with('html', $html);
}
/**
* Function to display the moons and pass data to the blade template
*/
public function displayMoons() {
//Get the user type from the user Auth class
$type = Auth::user()->user_type;
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//Update the prices for the moon
$moonCalc->FetchNewPrices();
//get all of the moons from the database
$moons = DB::table('Moons')->orderBy('System', 'asc')->get();
//declare the html variable and set it to null
$html = '';
foreach($moons as $moon) {
//Setup formats as needed
$spm = $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
$rentalEnd = date('m/d/Y', $moon->RentalEnd);
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
//Add the data to the html string to be passed to the view
$html .= '<tr>';
$html .= '<td>' . $spm . '</td>';
$html .= '<td>' . $moon->StructureName . '</td>';
$html .= '<td>' . $moon->FirstOre . '</td>';
$html .= '<td>' . $moon->FirstQuantity . '</td>';
$html .= '<td>' . $moon->SecondOre . '</td>';
$html .= '<td>' . $moon->SecondQuantity . '</td>';
$html .= '<td>' . $moon->ThirdOre . '</td>';
$html .= '<td>' . $moon->ThirdQuantity . '</td>';
$html .= '<td>' . $moon->FourthOre . '</td>';
$html .= '<td>' . $moon->FourthQuantity . '</td>';
if($type == 'W4RP') {
$html .= '<td>' . $price['alliance'] . '</td>';
} else if ($type == 'Legacy') {
$html .= '<td>' . $price['outofalliance'] . '</td>';
} else {
$html .= '<td>N/A</td>';
}
$html .= '<td>' . $moon->RentalCorp . '</td>';
$html .= '<td>' . $rentalEnd . '</td>';
$html .= '</tr>';
}
return view('moons.moon')->with('html', $html);
}

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropRolesColumnUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function(Blueprint $table) {
$table->dropColumn('role');
$table->dropColumn('scopes');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function(Blueprint $table) {
$table->string('role')->default('Guest');
$table->text('scopes')->nullable();
});
}
}

View File

@@ -9,8 +9,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">
<a class="dropdown-item" href="/moons/display">Display Moons</a>
@can('isUser')
<a class="dropdown-item" href="/moons/display/worth">Moon Worth</a>
@endcan
@can('isAdmin')
<a class="dropdown-item" href="/moons/admin/display">Display Moons</a>
<a class="dropdown-item" href="/moons/addmoon">Add Moon</a>
<a class="dropdown-item" href="/moons/updatemoon">Update Moon</a>
@endcan

View File

@@ -0,0 +1,27 @@
@extends('layouts.b4')
@section('content')
<div class="container col-md-12">
<table class="table table-striped">
<thead>
<th>System</th>
<th>Name</th>
<th>First Ore</th>
<th>Quantity</th>
<th>Second Ore</th>
<th>Quantity</th>
<th>Third Ore</th>
<th>Quantity</th>
<th>Fourth Ore</th>
<th>Quantity</th>
<th>Rental Price</th>
<th>Ally Rental Price</th>
<th>Renter</th>
<th>Rental End</th>
</thead>
<tbody>
{!! $html !!}
</tbody>
</table>
</div>
</div>
@endsection

View File

@@ -14,7 +14,6 @@
<th>Fourth Ore</th>
<th>Quantity</th>
<th>Rental Price</th>
<th>Ally Rental Price</th>
<th>Renter</th>
<th>Rental End</th>
</thead>

View File

@@ -28,6 +28,7 @@ Route::get('/moons/display', 'MoonsController@displayMoons');
Route::get('/moons/addmoon', 'MoonsController@addMoon');
Route::get('/moons/updatemoon', 'MoonsController@updateMoon');
Route::get('/moons/display/worth', 'MoonsController@displayTotalWorthForm');
Route::get('/moons/admin/display', 'MoonsController@displayMoonsAdmin');
//Moon Controller POST requests
Route::post('storeMoon', 'MoonsController@storeMoon');
Route::post('storeUpdateMoon', 'MoonsController@storeUpdateMoon');