Browse Source

trying to add dropdowns to edit blades - mashes mkI

master
jk 3 years ago
parent
commit
6218fe6af7
  1. 5
      app/Http/Controllers/MasheController.php
  2. 6
      resources/views/mashes/edit.blade.php

5
app/Http/Controllers/MasheController.php

@ -50,7 +50,10 @@ class MasheController extends Controller
} }
public function edit($id){ public function edit($id){
$mash = Mashe::where('id', (int)$id)->first(); $mash = Mashe::where('id', (int)$id)->first();
return view('mashes.edit')->with('mash', $mash);
$beers = Summarie::orderBy('name')->get();
$selected_beer = $mash->beer_id;
$data = array('mash'=>$mash, 'beers'=>$beers, 'selected_beer'=>$selected_beer);
return view('mashes.edit')->with($data);
} }
public function update(Request $request, $id){ public function update(Request $request, $id){

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

@ -18,7 +18,11 @@
@csrf @csrf
<div class="form-group"> <div class="form-group">
<label for="beer_id">Beer ID</label> <label for="beer_id">Beer ID</label>
<input type="text" class="form-control" name="beer_id" value="{{$mash->beer_id}}" />
<select class="form-control" name="beer_id">
@foreach ($beers as $beer)
<option value="{{$beer->beer_id}}" {{ $selected_beer == $beer->beer_id ? 'selected="selected"' : '' }}>{{$beer->name}}</option>
@endforeach
</select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="temperature">Temperature</label> <label for="temperature">Temperature</label>

Loading…
Cancel
Save