public contract?

This commit is contained in:
2019-04-28 21:51:59 -05:00
parent 2b72ca4846
commit c273da3d5f
2 changed files with 66 additions and 58 deletions

View File

@@ -64,8 +64,18 @@ class ContractController extends Controller
//Fetch all of the current contracts from the database
$contracts = Contract::where('end_date', '>=', $today)
->where(['type' => 'public'])->get();
->where(['type' => 'public'])->toArray()->get();
//Count the number of bids, and add them to the arrays
foreach($contracts as $contract) {
$tempCount = Bid::where(['contract_id' => $contract['id']])->count('contract_id');
$bids = Bid::where(['contract_id' => $contract['id']])->toArray()->get();
$contract['bid_count'] = $tempCount;
$contract['bids'] = $bids;
}
/*
if($count($contract->contract_id) > 0) {
foreach($contract->contract_id as $id) {
//Get the bid data
@@ -77,11 +87,11 @@ class ContractController extends Controller
} else {
$bids = null;
}
*/
//Call for the view to be displayed
return view('contracts.publiccontracts')->with('contracts', $contracts)
->with('bids', $bids);
return view('contracts.publiccontracts')->with('contracts', $contracts);
}
/**

View File

@@ -7,7 +7,7 @@
</div>
<br>
@if(count($data))
@foreach($data as $contract)
@foreach($contracts as $contract)
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
@@ -27,23 +27,24 @@
</div>
<div class="card-body">
<div class="container">
End Date: {{ $contract['contract']->end_date }}
End Date: {{ $contract['end_date'] }}
</div>
<span class="border-dark">
<div class="container">
{{ $contract['contract']->body }}
{{ $contract['body'] }}
</div>
</span>
<hr>
<!-- Count the number of bids for the current contract -->
@if($contract['bid_count'] > 0)
<span class="border-dark">
@if(isset($contract['bids']))
<table class="table table-striped">
<thead>
<th>Corporation</th>
<th>Amount</th>
</thead>
<tbody>
@foreach($contract['bids'] as $bid)
@foreach($contracts['bids'] as $bid)
<tr>
<td>{{ $bid['corporation_name'] }}</td>
<td>{{ $bid['bid_amount'] }}</td>
@@ -64,17 +65,14 @@
@endforeach
</tbody>
</table>
@else
No Bids have been entered.
@endif
</span>
@endif
</div>
</div>
</div>
</div>
</div>
@endforeach
<br>
@else
@include('contracts.includes.nocontracts')
@endif