这个想法是,我有一个页面,用户可以在其中竞标。这是视图。
auction.blade.php
<table class="table table-aukcija table-clear">
<tbody>
<tr>
<td>Auction No</td>
<td>{{ $auction->id }}</td>
</tr>
<tr>
<td>Time:</td>
<td class="counter_polje">
<strong id="clockdiv"></strong>
<br>
<small><em>( {{ date($auction->end_date) }} )</em></small>
</td>
</tr>
<tr>
<td>Number of Offers:
<!-- Here num of offers shall be displayed -->
</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td>My offer:</td>
</tr>
<tr>
<td colspan="2" class="table-nudjenje-biding">
<form id="formMojaPonuda" name="formMojaPonuda" action="{{ asset('/auctions/'.$auction->id) }}" method="GET"
enctype="multipart/form-data">
{{ csrf_field() }}
<div class="input-group">
<input type="hidden" name="id" id="minBid" value="{{ $auction->id }}">
<input type="hidden" name="name" id="minBid" value="{{ $auction->name }}">
<input type="hidden" name="descript" id="minBid" value="{{ $auction->descript }}">
<input type="hidden" name="price" id="minBid" value="{{ $auction->price }}">
<input type="hidden" name="end_date" id="minBid" value="{{ $auction->end_date }}">
<input name="txtIznos" id="bidValue" type="text" autocomplete="off" placeholder="(min. RSD 1.50)"
class="form-control">
<span class="input-group-btn">
<button type="submit" class="btn btn-success" name='offerButton'>Make your offer</button>
</span>
</div>
</form>
</td>
</tr>
</tbody>
</table>
web.php
Route::get('/auctions/{id}', 'AuctionController@show');
AuctionController.php
class AuctionController extends Controller
{
public function show($id)
{
$auction = new Auction();
$auction->id = $id;
$this->data['auction'] = $auction->get();
return view('pages.auction', $this->data);
}
}
Auction.php(模型)
class Auction
{
public $id;
public $name;
public $descript;
public $price;
public $pic;
public $end_date;
public $numOfOffers;
public function getAll()
{
return DB::table('auctions')->select('*')->get();
}
public function get()
{
return DB::table(a 'auctions')->select('*')->where('id', '=', $this->id);
}
}
因此,当用户提出要约并单击offerButton(“提出要约”)时,该拍卖的要约数应在数据库中增加。对于每次拍卖,可以有多个要约,应在相应的字段中显示该次拍卖的要约。但是,我不知道该如何实施?我尝试将按钮路由到同一路由(Route::get('/auctions/{id}', 'AuctionController@show');
),但是失败。有人能指出我正确的方向吗?