Browse Source

adding dropdown menus to grainbill create blade, mkIII

master
jk 3 years ago
parent
commit
2876e46699
  1. 4
      app/Http/Controllers/GrainbillController.php
  2. 4
      resources/views/grainbills/create.blade.php

4
app/Http/Controllers/GrainbillController.php

@ -74,8 +74,8 @@ class GrainbillController extends Controller
} }
public function create() public function create()
{ {
$beers = Summarie::orderBy('name')->get('beer_id','name');
$grains = Grain::orderBy('name')->get('id','name');
$beers = Summarie::orderBy('name')->value('beer_id', 'name');
$grains = Grain::orderBy('name')->value('id', 'name');
$data = array('beers'=>$beers, 'grains'=>$grains); $data = array('beers'=>$beers, 'grains'=>$grains);
return view('grainbills.create')->with($data); return view('grainbills.create')->with($data);
} }

4
resources/views/grainbills/create.blade.php

@ -20,7 +20,7 @@
<label for="beer_id">Beer ID</label> <label for="beer_id">Beer ID</label>
<select> <select>
@foreach ($beers as $beer) @foreach ($beers as $beer)
<option name="beer_id" value="{{$beer->beer_id}}">{{$beer->name}} (ID: {{$beer->beer_id}})</option>
<option name="beer_id" value="{{$beer->beer_id}}">"{{$beer->name}} (ID: {{$beer->beer_id}})"</option>
@endforeach @endforeach
</select> </select>
</div> </div>
@ -28,7 +28,7 @@
<label for="grain_id">Grain ID</label> <label for="grain_id">Grain ID</label>
<select> <select>
@foreach ($grains as $grain) @foreach ($grains as $grain)
<option name="grain_id" value="{{$grain->id}}">{{$grain->name}} (ID: {{$grain->id}})</option>
<option name="grain_id" value="{{$grain->id}}">{{$grain->name}}</option>
@endforeach @endforeach
</select> </select>
</div> </div>

Loading…
Cancel
Save