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