middleware('auth');
$this->middleware('role:User');
}
/**
* 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 .= '
';
$html .= '| ' . $spm . ' | ';
$html .= '' . $moon->StructureName . ' | ';
$html .= '' . $moon->FirstOre . ' | ';
$html .= '' . $moon->FirstQuantity . ' | ';
$html .= '' . $moon->SecondOre . ' | ';
$html .= '' . $moon->SecondQuantity . ' | ';
$html .= '' . $moon->ThirdOre . ' | ';
$html .= '' . $moon->ThirdQuantity . ' | ';
$html .= '' . $moon->FourthOre . ' | ';
$html .= '' . $moon->FourthQuantity . ' | ';
if($type == 'W4RP') {
$html .= '' . $price['alliance'] . ' | ';
} else if ($type == 'Legacy') {
$html .= '' . $price['outofalliance'] . ' | ';
} else {
$html .= 'N/A | ';
}
$html .= '' . $moon->RentalCorp . ' | ';
$html .= '' . $rentalEnd . ' | ';
$html .= '
';
}
return view('moons.moon')->with('html', $html);
}
public function displayTotalWorthForm() {
return view('moons.formTotalWorth');
}
public function displayTotalWorth(Request $request) {
$firstOre = $request->firstOre;
$firstQuantity = $request->firstQuantity;
$secondOre = $request->secondOre;
$secondQuantity = $request->secondQuantity;
$thirdOre = $request->thirdOre;
$thirdQuantity = $request->thirdQuantity;
$fourthOre = $request->fourthOre;
$fourthQuantity = $request->fourthQuantity;
//Setup calls to the MoonCalc class
$moonCalc = new MoonCalc();
//Update the prices for the moon
$moonCalc->FetchNewPrices();
$totalGoo = $moonCalc->SpatialMoonsOnlyGooTotalWorth($firstOre, $firstQuantity,
$secondOre, $secondQuantity,
$thirdOre, $thirdQuantity,
$fourthOre, $fourthQuantity);
$totalGoo = number_format($totalGoo, 2, ".", ",");
$totalWorth = $moonCalc->SpatialMoonsTotalWorth($firstOre, $firstQuantity,
$secondOre, $secondQuantity,
$thirdOre, $thirdQuantity,
$fourthOre, $fourthQuantity);
$totalWorth = number_format($totalWorth, 2, ".", ",");
return view('moons.displayTotalWorth')->with(['totalWorth' => $totalWorth, 'totalGoo' => $totalGoo]);
}
}