Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b6db2f200b |
@@ -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()
|
||||
|
||||
@@ -49,3 +49,21 @@ If you discover a security vulnerability within Laravel, please send an e-mail t
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
||||
|
||||
## Changelog
|
||||
|
||||
### [bidder-facing-checkout] - 2026-04-24
|
||||
|
||||
#### Added
|
||||
- **Public Winnings View:** Introduced a new feature allowing bidders to check their won items by entering their bidder number.
|
||||
- **Routes:** Added `/mywinnings` (GET and POST) routes to `routes/web.php`.
|
||||
- **Controller Logic:** Implemented `myWinnings` method in `PagesController` to handle bidder lookups and display results.
|
||||
- **Views:**
|
||||
- `resources/views/mywinnings_form.blade.php`: Search form for bidder number.
|
||||
- `resources/views/mywinnings_results.blade.php`: Detailed list of won items and total cost.
|
||||
- **Navigation:** Added "Check My Winnings" link to the main layout navbar for easy public access.
|
||||
- **Testing:** Created `tests/Feature/MyWinningsTest.php` to ensure the new feature works as expected.
|
||||
|
||||
#### Changed
|
||||
- **Models:** Updated `App\Models\WinningBids` relationship `items()` from `hasOne` to `belongsTo` to correctly map the database structure and support eager loading.
|
||||
|
||||
|
||||
@@ -202,6 +202,11 @@
|
||||
Checkout Bidder
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/mywinnings">
|
||||
Check My Winnings
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Right Side Of Navbar -->
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Check My Winnings</div>
|
||||
|
||||
<div class="panel-body">
|
||||
@if (isset($error))
|
||||
<div class="alert alert-danger">
|
||||
{{ $error }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form class="form-horizontal" method="POST" action="/mywinnings">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="bidder_number" class="col-md-4 control-label">Bidder Number</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="bidder_number" type="text" class="form-control" name="bidder_number" value="{{ old('bidder_number') }}" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-8 col-md-offset-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Check Winnings
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,49 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Winnings for Bidder #{{ $bidder->bidder_assigned_number }} - {{ $bidder->bidder_fname }} {{ $bidder->bidder_lname }}</div>
|
||||
|
||||
<div class="panel-body">
|
||||
@if($winnings->count() > 0)
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item #</th>
|
||||
<th>Description</th>
|
||||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($winnings as $winning)
|
||||
<tr>
|
||||
<td>{{ $winning->items->item_assigned_num }}</td>
|
||||
<td>{{ $winning->items->item_desc }}</td>
|
||||
<td>${{ number_format($winning->winning_cost, 2) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="2" class="text-right">Total:</th>
|
||||
<th>${{ number_format($total_cost, 2) }}</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
@else
|
||||
<p>No winning bids found for this bidder number.</p>
|
||||
@endif
|
||||
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<a href="/mywinnings" class="btn btn-default">Back to Search</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -20,6 +20,8 @@ Route::get('winningbidderlist', [ 'uses' => 'PagesController@winningbidderlist']
|
||||
Route::get('showwinners', [ 'uses' => 'PagesController@showwinners']);
|
||||
Route::get('showscores', [ 'uses' => 'PagesController@showscores']);
|
||||
Route::get('showscoresbycar', [ 'uses' => 'PagesController@showscoresbycar']);
|
||||
Route::get('mywinnings', [ 'uses' => 'PagesController@myWinnings']);
|
||||
Route::post('mywinnings', [ 'uses' => 'PagesController@myWinnings']);
|
||||
|
||||
Route::group(['middleware' => 'auth'], function() {
|
||||
Route::get('bidders', [ 'uses' => 'PagesController@bidders']);
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use App\Models\Bidders;
|
||||
use App\Models\Items;
|
||||
use App\Models\WinningBids;
|
||||
|
||||
class MyWinningsTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function test_mywinnings_form_is_accessible()
|
||||
{
|
||||
$response = $this->get('/mywinnings');
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Check My Winnings');
|
||||
}
|
||||
|
||||
public function test_mywinnings_results_show_correct_data()
|
||||
{
|
||||
// Create a bidder
|
||||
$bidder = Bidders::create([
|
||||
'bidder_assigned_number' => '999',
|
||||
'bidder_fname' => 'Test',
|
||||
'bidder_lname' => 'User',
|
||||
]);
|
||||
|
||||
// Create an item
|
||||
$item = Items::create([
|
||||
'item_assigned_num' => '777',
|
||||
'item_desc' => 'Test Item',
|
||||
'item_min_bid' => 10,
|
||||
'item_est_value' => 20,
|
||||
]);
|
||||
|
||||
// Create a winning bid
|
||||
WinningBids::create([
|
||||
'winning_bidder_num' => $bidder->idbidders,
|
||||
'winning_item_num' => $item->iditems,
|
||||
'winning_cost' => 15,
|
||||
]);
|
||||
|
||||
$response = $this->post('/mywinnings', [
|
||||
'bidder_number' => '999'
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Winnings for Bidder #999');
|
||||
$response->assertSee('Test Item');
|
||||
$response->assertSee('$15.00');
|
||||
}
|
||||
|
||||
public function test_mywinnings_invalid_bidder_shows_error()
|
||||
{
|
||||
$response = $this->post('/mywinnings', [
|
||||
'bidder_number' => 'NONEXISTENT'
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('Bidder number not found.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user