diff --git a/app/Http/Controllers/MoonsAdminController.php b/app/Http/Controllers/MoonsAdminController.php index 13589eb15..c8e7636da 100644 --- a/app/Http/Controllers/MoonsAdminController.php +++ b/app/Http/Controllers/MoonsAdminController.php @@ -208,34 +208,46 @@ class MoonsAdminController extends Controller //get all of the moons from the database $moons = Moon::orderBy('System', 'asc')->get(); //declare the html variable and set it to null - $html = ''; + $table = array(); foreach($moons as $moon) { //Setup formats as needed $spm = $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon; - $rentalEnd = new Carbon($moon->RentalEnd); - $rentalEnd = $rentalEnd->format('m-d'); + $rentalTemp = new Carbon($moon->RentalEnd); + $rentalEnd = $rentalTemp->format('m-d'); $price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity); + if($type == 'W4RP') { + $moonprice = $price['alliance']; + } else { + $moonprice = $price['outofalliance']; + } + + if($today > $rentalTemp) { + $color = 'table-success'; + } else { + $color = 'table-danger'; + } + //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 . ''; - $html .= '' . $price['alliance'] . ''; - $html .= '' . $price['outofalliance'] . ''; - $html .= '' . $moon->RentalCorp . ''; - $html .= '' . $rentalEnd . ''; - $html .= ''; + array_push($table, [ + 'SPM' => $spm, + 'StructureName' => $moon->StructureName, + 'FirstOre' => $moon->FirstOre, + 'FirstQuantity' => $moon->FirstQuantity, + 'SecondOre' => $moon->SecondOre, + 'SecondQuantity' => $moon->SecondQuantity, + 'ThirdOre' => $moon->ThirdOre, + 'ThirdQuantity' => $moon->ThirdQuantity, + 'FourthOre' => $moon->FourthOre, + 'FourthQuantity' => $moon->FourthQuantity, + 'Price' => $moonprice, + 'Worth' => number_format($worth, "2", ".", ","), + 'RentalEnd' => $rentalEnd, + 'RowColor' => $color, + ]); } - return view('moons/admin/adminmoon')->with('html', $html); + return view('moons/admin/adminmoon')->with('table', $table); } } diff --git a/app/Http/Controllers/MoonsController.php b/app/Http/Controllers/MoonsController.php index 915585f01..ae944a853 100644 --- a/app/Http/Controllers/MoonsController.php +++ b/app/Http/Controllers/MoonsController.php @@ -36,7 +36,7 @@ class MoonsController extends Controller //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 = ''; + $table = array(); $moonprice = null; foreach($moons as $moon) { diff --git a/resources/views/moons/admin/adminmoon.blade.php b/resources/views/moons/admin/adminmoon.blade.php index bab569f41..05c3e5906 100644 --- a/resources/views/moons/admin/adminmoon.blade.php +++ b/resources/views/moons/admin/adminmoon.blade.php @@ -19,7 +19,23 @@ Rental End - {!! $html !!} + @foreach($table as $row) + + {{ $row['SPM'] }} + {{ $row['StructureName'] }} + {{ $row['FirstOre'] }} + {{ $row['FirstQuantity'] }} + {{ $row['SecondOre'] }} + {{ $row['SecondQuantity'] }} + {{ $row['ThirdOre'] }} + {{ $row['ThirdQuantity'] }} + {{ $row['FourthOre'] }} + {{ $row['FourthQuantity'] }} + {{ $row['Price'] }} + {{ $row['Worth'] }} + {{ $row['RentalEnd'] }} + + @endforeach