From 61b0e2f6dc7676d991bb56e00bad835fcb764016 Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Mon, 29 Apr 2019 01:41:29 -0500 Subject: [PATCH] modify bids --- app/Http/Controllers/ContractController.php | 17 ++++++++++++++++- .../views/contracts/includes/private.blade.php | 11 ++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ContractController.php b/app/Http/Controllers/ContractController.php index fe59c0f94..58835854e 100644 --- a/app/Http/Controllers/ContractController.php +++ b/app/Http/Controllers/ContractController.php @@ -87,12 +87,27 @@ class ContractController extends Controller * Controller function to display current private contracts */ public function displayPrivateContracts() { + //Declare our array variables + $bids = array(); + $contracts = array(); + //Calucate today's date to know which contracts to display $today = Carbon::now(); //Fetch all of the current contracts from the database - $contracts = Contract::where('end_date', '>=', $today) + $contractTemp = Contract::where('end_date', '>=', $today) ->where(['type' => 'private'])->get(); + + //Count the number of bids, and add them to the arrays + for($i = 0; $i < sizeof($contractsTemp); $i++) { + $tempCount = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->count('contract_id'); + $bids = Bid::where(['contract_id' => $contractsTemp[$i]['contract_id']])->get()->toArray(); + + //Assemble the finaly array + $contracts[$i] = $contractsTemp[$i]; + $contracts[$i]['bid_count'] = $tempCount; + $contracts[$i]['bids'] = $bids; + } return view ('contracts.privatecontracts')->with('contracts', $contracts); } diff --git a/resources/views/contracts/includes/private.blade.php b/resources/views/contracts/includes/private.blade.php index 880a331e7..3b0c1febe 100644 --- a/resources/views/contracts/includes/private.blade.php +++ b/resources/views/contracts/includes/private.blade.php @@ -1,3 +1,4 @@ +@foreach($contracts as $contract)
@@ -24,9 +25,17 @@ {{ $contract['body'] }}
+
+ @foreach($contract['bids'] as $bid) + @if(auth()->user()->character_id == $bid['character_id']) + Modify Bid + Delete Bid + @endif + @endforeach
-
\ No newline at end of file +
+@endforeach \ No newline at end of file