Browse Source

trying to add dropdowns to edit blades

master
jk 3 years ago
parent
commit
99ff3914ee
  1. 4
      app/Http/Controllers/SummarieController.php
  2. 6
      resources/views/beers/edit.blade.php

4
app/Http/Controllers/SummarieController.php

@ -87,7 +87,9 @@ class SummarieController extends Controller
public function edit($id){ public function edit($id){
$beer = Summarie::where('beer_id', (int)$id)->first(); $beer = Summarie::where('beer_id', (int)$id)->first();
return view('beers.edit')->with('beer', $beer);
$selected_brewery = $beer('brewery_id');
$data = array('beer'=>$beer, 'selected_brewery'=>$selected_brewery)
return view('beers.edit')->with($data);
} }
public function update(Request $request, $id) public function update(Request $request, $id)

6
resources/views/beers/edit.blade.php

@ -51,7 +51,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="brewery_id">Brewery ID</label> <label for="brewery_id">Brewery ID</label>
<input type="text" class="form-control" name="brewery_id" value="{{ $beer->brewery_id }}" />
<select class="form-control" name="brewery_id">
@foreach ($breweries as $brewery)
<option value="{{$brewery->id}}" {{ $selected_brewery == $brewery->id ? 'selected="selected"' : '' }}>{{$brewery->name}}</option>
@endforeach
</select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="batch">Batch Size (L)</label> <label for="batch">Batch Size (L)</label>

Loading…
Cancel
Save