row colors for the table

This commit is contained in:
2019-02-23 22:55:13 -06:00
parent f455c9a6a4
commit 814b2462cb
3 changed files with 50 additions and 22 deletions

View File

@@ -208,34 +208,46 @@ class MoonsAdminController extends Controller
//get all of the moons from the database //get all of the moons from the database
$moons = Moon::orderBy('System', 'asc')->get(); $moons = Moon::orderBy('System', 'asc')->get();
//declare the html variable and set it to null //declare the html variable and set it to null
$html = ''; $table = array();
foreach($moons as $moon) { foreach($moons as $moon) {
//Setup formats as needed //Setup formats as needed
$spm = $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon; $spm = $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon;
$rentalEnd = new Carbon($moon->RentalEnd); $rentalTemp = new Carbon($moon->RentalEnd);
$rentalEnd = $rentalEnd->format('m-d'); $rentalEnd = $rentalTemp->format('m-d');
$price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $price = $moonCalc->SpatialMoonsOnlyGoo($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity); $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 //Add the data to the html string to be passed to the view
$html .= '<tr>'; array_push($table, [
$html .= '<td>' . $spm . '</td>'; 'SPM' => $spm,
$html .= '<td>' . $moon->StructureName . '</td>'; 'StructureName' => $moon->StructureName,
$html .= '<td>' . $moon->FirstOre . '</td>'; 'FirstOre' => $moon->FirstOre,
$html .= '<td>' . $moon->FirstQuantity . '</td>'; 'FirstQuantity' => $moon->FirstQuantity,
$html .= '<td>' . $moon->SecondOre . '</td>'; 'SecondOre' => $moon->SecondOre,
$html .= '<td>' . $moon->SecondQuantity . '</td>'; 'SecondQuantity' => $moon->SecondQuantity,
$html .= '<td>' . $moon->ThirdOre . '</td>'; 'ThirdOre' => $moon->ThirdOre,
$html .= '<td>' . $moon->ThirdQuantity . '</td>'; 'ThirdQuantity' => $moon->ThirdQuantity,
$html .= '<td>' . $moon->FourthOre . '</td>'; 'FourthOre' => $moon->FourthOre,
$html .= '<td>' . $moon->FourthQuantity . '</td>'; 'FourthQuantity' => $moon->FourthQuantity,
$html .= '<td>' . $price['alliance'] . '</td>'; 'Price' => $moonprice,
$html .= '<td>' . $price['outofalliance'] . '</td>'; 'Worth' => number_format($worth, "2", ".", ","),
$html .= '<td>' . $moon->RentalCorp . '</td>'; 'RentalEnd' => $rentalEnd,
$html .= '<td>' . $rentalEnd . '</td>'; 'RowColor' => $color,
$html .= '</tr>'; ]);
} }
return view('moons/admin/adminmoon')->with('html', $html); return view('moons/admin/adminmoon')->with('table', $table);
} }
} }

View File

@@ -36,7 +36,7 @@ class MoonsController extends Controller
//get all of the moons from the database //get all of the moons from the database
$moons = DB::table('Moons')->orderBy('System', 'asc')->get(); $moons = DB::table('Moons')->orderBy('System', 'asc')->get();
//declare the html variable and set it to null //declare the html variable and set it to null
$html = '';
$table = array(); $table = array();
$moonprice = null; $moonprice = null;
foreach($moons as $moon) { foreach($moons as $moon) {

View File

@@ -19,7 +19,23 @@
<th>Rental End</th> <th>Rental End</th>
</thead> </thead>
<tbody> <tbody>
{!! $html !!} @foreach($table as $row)
<tr class="{{ $row['RowColor'] }}">
<td>{{ $row['SPM'] }}</td>
<td>{{ $row['StructureName'] }}</td>
<td>{{ $row['FirstOre'] }}</td>
<td>{{ $row['FirstQuantity'] }}</td>
<td>{{ $row['SecondOre'] }}</td>
<td>{{ $row['SecondQuantity'] }}</td>
<td>{{ $row['ThirdOre'] }}</td>
<td>{{ $row['ThirdQuantity'] }}</td>
<td>{{ $row['FourthOre'] }}</td>
<td>{{ $row['FourthQuantity'] }}</td>
<td>{{ $row['Price'] }}</td>
<td>{{ $row['Worth'] }}</td>
<td>{{ $row['RentalEnd'] }}</td>
</tr>
@endforeach
</tbody> </tbody>
</table> </table>
</div> </div>