Add customer-facing check for winning items
This commit is contained in:
@@ -515,4 +515,30 @@ class PagesController extends Controller
|
||||
//dd($showcarlist_results);
|
||||
return view('showcarlist', ['showcarlist_results' => $showcarlist_results]);
|
||||
}
|
||||
|
||||
public function myWinnings(Request $request)
|
||||
{
|
||||
if (!$request->bidder_number) {
|
||||
return view('mywinnings_form');
|
||||
}
|
||||
|
||||
$bidder_number = $request->bidder_number;
|
||||
$bidder = Bidders::where('bidder_assigned_number', $bidder_number)->first();
|
||||
|
||||
if (!$bidder) {
|
||||
return view('mywinnings_form', ['error' => 'Bidder number not found.']);
|
||||
}
|
||||
|
||||
$winnings = WinningBids::with('items')
|
||||
->where('winning_bidder_num', $bidder->idbidders)
|
||||
->get();
|
||||
|
||||
$total_cost = $winnings->sum('winning_cost');
|
||||
|
||||
return view('mywinnings_results', [
|
||||
'bidder' => $bidder,
|
||||
'winnings' => $winnings,
|
||||
'total_cost' => $total_cost
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class WinningBids extends Model
|
||||
|
||||
public function items()
|
||||
{
|
||||
return $this->hasOne(Items::class, 'iditems', 'winning_item_num');
|
||||
return $this->belongsTo(Items::class, 'winning_item_num', 'iditems');
|
||||
}
|
||||
|
||||
public function bidders()
|
||||
|
||||
Reference in New Issue
Block a user