0
我爲我的列表插入降低的出行價格。在我的表單中,我顯示了該列表的所有行程。我不知道如何將已經存在的旅行名稱插入到數據庫中。我會告訴你我的意思。 (我不是編輯之旅,我'創造一個促銷上市,所以行程名稱和更低的價格將進入一個不同勢表)我需要插入左側如何從表單中獲取文本並將其插入數據庫 - Laravel 5.2
的「旅行」的名字
我這是怎麼了表格佈局:
<form class="form" method="post" action="{{ route('user.promotion-store') }}">
{{ csrf_field() }}
<table class="table table-hover table-striped">
<thead>
<tr>
<th>Trip</th>
<th>Price</th>
<th>Reduced Price</th>
</tr>
</thead>
<tbody>
@foreach($listings->trips as $trip)
<tr>
<td>
{{ $trip->name }}
</td>
<td>
${{ $trip->cost }}
</td>
<td>
<div class="col-md-12">
<div class="form-group{{ $errors->has('reduced_trip_price') ? ' has-error' : '' }}">
<label>Your Reduced Price</label>
<input type="text" class="form-control" name="reduced_trip_price" id="reduced_trip_price" placeholder="Optional...">
@if($errors->has('reduced_trip_price'))
<span class="help-block">{{ $errors->first('reduced_trip_price') }}</span>
@endif
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
這是我怎麼插入:
public function store(ReducedTripRequest $request) {
$reducedTrips = ReducedTrips($request->all());
$reducedTrips->save();
return redirect()->back();
}
是那完美! – David