diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index 7ca178d..ee7ed8b 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -75,28 +75,17 @@ class PagesController extends Controller return view('checkout_select_form'); } elseif (!$checkout_req->checkout_payment_method) { $checkout_bidder = $checkout_req->checkoutbiddernum; - $checkout_list_results = DB::select("SELECT - *, items.item_assigned_num - FROM winning_bids - INNER JOIN items AS items - ON winning_bids.winning_item_num=items.iditems - WHERE winning_bidder_num = $checkout_bidder - "); - WinningBids::with('items') + $checkout_list_results = WinningBids::with('items') ->where('winning_bidder_num', $checkout_bidder) ->get(); - $checkout_info_results = DB::select("SELECT - winning_bids.*, - bidders.*, - sum(winning_cost) AS total_cost - FROM winning_bids - INNER JOIN bidders AS bidders - ON winning_bids.winning_bidder_num=bidders.idbidders - WHERE winning_bidder_num = $checkout_bidder - GROUP BY winning_bids.winning_bidder_num - "); + $checkout_info_results = WinningBids::with('bidders') + ->where('winning_bidder_num', $checkout_bidder) + ->get(); + $checkout_cost_result = WinningBids::where('winning_bidder_num', $checkout_bidder) + ->sum('winning_cost'); return view('checkout', [ 'checkout_list_results' => $checkout_list_results, + '$checkout_cost_result' => $checkout_cost_result, 'checkout_info_results' => $checkout_info_results ]); } else { @@ -106,23 +95,15 @@ class PagesController extends Controller $check_number = $checkout_req->check_number; $cc_transaction = $checkout_req->cc_transaction; $cc_amount = $checkout_req->cc_amount; - $checkout_list_results = DB::select("SELECT - *, items.item_assigned_num, items.item_desc - FROM winning_bids - INNER JOIN items AS items - ON winning_bids.winning_item_num=items.iditems - WHERE winning_bidder_num = $bidder_num - "); - $checkout_info_results = DB::select("SELECT - winning_bids.*, - bidders.*, - sum(winning_cost) AS total_cost - FROM winning_bids - INNER JOIN bidders AS bidders - ON winning_bids.winning_bidder_num=bidders.idbidders - WHERE winning_bidder_num = $bidder_num - GROUP BY winning_bids.winning_bidder_num - "); + $checkout_list_results = WinningBids::with('items') + ->where('winning_bidder_num', $checkout_bidder) + ->get(); + $checkout_cost_result = WinningBids::where('winning_bidder_num', $checkout_bidder) + ->sum('winning_cost'); + + $checkout_info_results = WinningBids::with('bidders') + ->where('winning_bidder_num', $bidder_num) + ->get(); $checkout_result = DB::table('checkout')->insertGetID( [ 'bidder_num' => $bidder_num, diff --git a/resources/views/checkout.blade.php b/resources/views/checkout.blade.php index a29841d..9fe1bc8 100644 --- a/resources/views/checkout.blade.php +++ b/resources/views/checkout.blade.php @@ -6,48 +6,43 @@
Checkout
-
{{ csrf_field() }} @foreach($checkout_info_results as $checkout_info_result) - @php - $bidnum = $checkout_info_result->idbidders; - $totaldue = $checkout_info_result->total_cost; - @endphp @endforeach @@ -65,7 +60,7 @@ @foreach($checkout_list_results as $checkout_list_result)

- Bidder Number: {{ $checkout_info_result->bidder_assigned_number }} + Bidder Number: {{ $checkout_info_result->bidders->bidder_assigned_number }}

- Total: ${{ $checkout_info_result->total_cost }} + Total: ${{ $checkout_cost_result }}

- Name: {{ $checkout_info_result->bidder_fname }} {{ $checkout_info_result->bidder_lname }} + Name: {{ $checkout_info_result->bidders->bidder_fname }} {{ $checkout_info_result->bidders->bidder_lname }} - Phone Number: {{ $checkout_info_result->bidder_phone }} + Phone Number: {{ $checkout_info_result->bidders->bidder_phone }}
- Address: {{ $checkout_info_result->bidder_addr }} + Address: {{ $checkout_info_result->bidders->bidder_addr }} - City: {{ $checkout_info_result->bidder_city }} + City: {{ $checkout_info_result->bidders->bidder_city }} - State: {{ $checkout_info_result->bidder_state }} + State: {{ $checkout_info_result->bidders->bidder_state }} - Zip: {{ $checkout_info_result->bidder_zip }} + Zip: {{ $checkout_info_result->bidders->bidder_zip }}
- {{ $checkout_list_result->item_assigned_num }} + {{ $checkout_list_result->items->item_assigned_num }} ${{ $checkout_list_result->winning_cost }} @@ -109,8 +104,8 @@ - - + + bidders->idbidders }}>