connection = 'redis'; //Set the variables $contractId = $contract->contract_id; $issuerId = $contract->issuer_id; $issuerName = $contract->issuer_name; $title = $contract->title; $endDate = $contract->end_date; $deliveryBy = $contract->delivery_by; $body = $contract->body; $state = $contract->state; $finalCost = $contract->final_cost; } /** * Execute the job. * * @return void */ public function handle() { //Declare variables $bidId = null; $bidAmount = null; //Get all of the bids from the contract $bids = SupplyChainBids::where([ 'contract_id' => $contractId, ])->get(); //Loop through the bids and find the lowest bid foreach($bids as $bid) { if($bidId == null) { $bidId = $bid->id; $bidAmount = $bid->bid_amount; } else { if($bid->bid_amount < $bidAmount) { $bidId = $bid->id; $bidAmount = $bid->bid_amount; } } } //Clean up the bids and update the contract with the winning bid SupplyChainContract::where([ 'contract_id' => $this->contractId, ])->update([ 'final_cost' => $bidAmount, 'winning_bid_id' => $bidId, ]); } }