diff --git a/app/Http/Controllers/ContractController.php b/app/Http/Controllers/ContractController.php index 8072ec521..7d58bb0b5 100644 --- a/app/Http/Controllers/ContractController.php +++ b/app/Http/Controllers/ContractController.php @@ -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); } /** diff --git a/resources/views/contracts/publiccontracts.blade.php b/resources/views/contracts/publiccontracts.blade.php index 439c3bd25..2a2aac3c1 100644 --- a/resources/views/contracts/publiccontracts.blade.php +++ b/resources/views/contracts/publiccontracts.blade.php @@ -7,74 +7,72 @@
@if(count($data)) -@foreach($data as $contract) +@foreach($contracts as $contract)
-
-
-
-
-
-
- {{ $contract['contract']->title }} -
-
- Type: Public -
- +
+
+
+
+
+
+ {{ $contract['contract']->title }} +
+
+ Type: Public +
+
-
+
+
+
+ End Date: {{ $contract['end_date'] }} +
+
- End Date: {{ $contract['contract']->end_date }} + {{ $contract['body'] }}
+
+
+ + @if($contract['bid_count'] > 0) -
- {{ $contract['contract']->body }} -
-
-
- - @if(isset($contract['bids'])) - - - - - - @foreach($contract['bids'] as $bid) - - - - @if(auth()->user()->character_id == $bid['character_id']) - {{ Form::open(['action' => 'ContractController@displayModifyBid', 'method' => 'POST']) }} - {{ Form::hidden('id', $bid['id']) }} - {{ Form::hidden('contract_id', $bid['contract_id']) }} - {{ Form::submit('Modify Bid', ['class' => 'btn btn-primary']) }} - {!! Form::close() !!} - - {{ Form::open(['action' => 'ContractController@deleteBid', 'method' => 'POST']) }} - {{ Form::hidden('id', $bid['id']) }} - {{ Form::hidden('contract_id', $bid['contract_id']) }} - {{ Form::submit('Delete Bid', ['class' => 'btn btn-primary']) }} - {!! Form::close() !!} - @endif - - @endforeach - -
CorporationAmount
{{ $bid['corporation_name'] }}{{ $bid['bid_amount'] }}
- @else - No Bids have been entered. - @endif + + Corporation + Amount + + + @foreach($contracts['bids'] as $bid) + + {{ $bid['corporation_name'] }} + {{ $bid['bid_amount'] }} + @if(auth()->user()->character_id == $bid['character_id']) + {{ Form::open(['action' => 'ContractController@displayModifyBid', 'method' => 'POST']) }} + {{ Form::hidden('id', $bid['id']) }} + {{ Form::hidden('contract_id', $bid['contract_id']) }} + {{ Form::submit('Modify Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} + + {{ Form::open(['action' => 'ContractController@deleteBid', 'method' => 'POST']) }} + {{ Form::hidden('id', $bid['id']) }} + {{ Form::hidden('contract_id', $bid['contract_id']) }} + {{ Form::submit('Delete Bid', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} + @endif + + @endforeach + +
-
+ @endif
+
@endforeach -
@else @include('contracts.includes.nocontracts') @endif