moon display
This commit is contained in:
@@ -12,15 +12,37 @@ use DB;
|
|||||||
|
|
||||||
class MoonsController extends Controller
|
class MoonsController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Function to display the moons and pass data to the blade template
|
||||||
|
*/
|
||||||
public function displayMoons() {
|
public function displayMoons() {
|
||||||
|
//get all of the moons from the database
|
||||||
$moons = DB::table('moons')->get();
|
$moons = DB::table('moons')->get();
|
||||||
dd($moons);
|
//declare the html variable and set it to null
|
||||||
$html = '';
|
$html = '';
|
||||||
foreach($moons as $moon) {
|
foreach($moons as $moon) {
|
||||||
$html .= '<td>' . $moon['system'] . '</td>';
|
//Setup formats as needed
|
||||||
|
$spm = $moon['System'] . ' - ' . $moon['Planet'] . ' - ' . $moon['Moon'];
|
||||||
|
$rentalEnd = date('d.m.Y', $moon['RentalEnd']);
|
||||||
|
//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>';
|
||||||
|
$html .= '<td>' . $moon['Price'] . '</td>';
|
||||||
|
$html .= '<td>' . $moon['Renter'] . '</td>';
|
||||||
|
$html .= '<td>' . $rentalEnd . '</td>';
|
||||||
|
$html .= '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('moons.moon')->with($moons);
|
return view('moons.moon')->with($html);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addMoon() {
|
public function addMoon() {
|
||||||
|
|||||||
@@ -20,24 +20,7 @@
|
|||||||
<th>Rental End</th>
|
<th>Rental End</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@if(sizeof($moons) > 0)
|
{{ $html }}
|
||||||
@foreach ($moons as $moon)
|
|
||||||
<tr>
|
|
||||||
<td>{{ $moon['system'] }}</td>
|
|
||||||
<td>{{ $moon['structure'] }}</td>
|
|
||||||
<td>{{ $moon['firstore'] }}</td>
|
|
||||||
<td>{{ $moon['firstquan'] }}</td>
|
|
||||||
<td>{{ $moon['secondore'] }}</td>
|
|
||||||
<td>{{ $moon['secondquan'] }}</td>
|
|
||||||
<td>{{ $moon['thirdore'] }}</td>
|
|
||||||
<td>{{ $moon['thirdquan'] }}</td>
|
|
||||||
<td>{{ $moon['fourthore'] }}</td>
|
|
||||||
<td>{{ $moon['price'] }}</td>
|
|
||||||
<td>{{ $moon['renter'] }}</td>
|
|
||||||
<td>{{ $moon['rentend'] }}</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
@endif
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user