moons controller

This commit is contained in:
2019-05-05 21:25:25 -05:00
parent b5327e3886
commit 1af82a151a

View File

@@ -30,6 +30,8 @@ class MoonsController extends Controller
* Function to display the moons and pass data to the blade template * Function to display the moons and pass data to the blade template
*/ */
public function displayMoons() { public function displayMoons() {
$rentalEnd = '';
//Get the user type from the user Auth class //Get the user type from the user Auth class
$type = Auth::user()->user_type; $type = Auth::user()->user_type;
//Setup calls to the MoonCalc class //Setup calls to the MoonCalc class
@@ -43,9 +45,15 @@ class MoonsController extends Controller
$table = array(); $table = array();
$moonprice = null; $moonprice = null;
foreach($moons as $moon) { foreach($moons as $moon) {
//get the rental data for the moon
$rental = MoonRent::where([
'System' => $moon->System,
'Planet' => $moon->Planet,
'Moon' => $moon->Moon,
])->first();
//Setup formats as needed //Setup formats as needed
$spm = $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon; $rentalTemp = new Carbon($rental->RentalEnd);
$rentalTemp = new Carbon($moon->RentalEnd);
$rentalEnd = $rentalTemp->format('m-d'); $rentalEnd = $rentalTemp->format('m-d');
$today = Carbon::now(); $today = Carbon::now();
@@ -77,7 +85,7 @@ class MoonsController extends Controller
//Add the data to the html string to be passed to the view //Add the data to the html string to be passed to the view
array_push($table, [ array_push($table, [
'SPM' => $spm, 'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
'StructureName' => $moon->StructureName, 'StructureName' => $moon->StructureName,
'FirstOre' => $moon->FirstOre, 'FirstOre' => $moon->FirstOre,
'FirstQuantity' => $moon->FirstQuantity, 'FirstQuantity' => $moon->FirstQuantity,