0
私のリスティングには旅行代金を差し引いています。私のフォームでは、そのリスティングのすべての旅行を表示します。私はどのように既存の旅行名をデータベースに挿入するかわかりません。私はあなたが何を意味するかを見せます。 フォームからテキストを取得してデータベースに挿入する方法 - Laravel 5.2
を(トリップ名と減少し価格が切り抜いた表になりますので、私は、I'amはプロモーションのリストを作成し、旅行を編集していないよ)私は左
の「旅」の名前を挿入する必要がありますこれは私が、フォームがレイアウトされている方法です。
<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();
}
はい、完璧なthatsの! – David