Browse Source

trying to add dropdowns to edit blades - fermentations mkI

master
jk 3 years ago
parent
commit
543798d35d
  1. 8
      app/Http/Controllers/FermentationController.php
  2. 2
      resources/views/adjunctadditions/create.blade.php
  3. 2
      resources/views/adjunctadditions/edit.blade.php
  4. 2
      resources/views/adjuncts/create.blade.php
  5. 2
      resources/views/adjuncts/edit.blade.php
  6. 2
      resources/views/beers/create.blade.php
  7. 2
      resources/views/beers/edit.blade.php
  8. 2
      resources/views/breweries/create.blade.php
  9. 2
      resources/views/breweries/edit.blade.php
  10. 2
      resources/views/fermentations/create.blade.php
  11. 25
      resources/views/fermentations/edit.blade.php
  12. 2
      resources/views/grainbills/create.blade.php
  13. 2
      resources/views/grainbills/edit.blade.php
  14. 2
      resources/views/grains/create.blade.php
  15. 2
      resources/views/grains/edit.blade.php
  16. 2
      resources/views/hopadditions/create.blade.php
  17. 2
      resources/views/hopadditions/edit.blade.php

8
app/Http/Controllers/FermentationController.php

@ -55,7 +55,13 @@ class FermentationController extends Controller
}
public function edit($id){
$fermentation = Fermentation::where('id', (int)$id)->first();
return view('fermentations.edit')->with('fermentation', $fermentation);
$beers = Summarie::orderBy('name')->get();
$selected_beer = $fermentation->beer_id;
$yeasts = Yeast::orderBy('name')->get();
$selected_yeast = $fermentation->yeast_id;
$selected_alt = $fermenation->alternative;
$data = array('fermentation'=>$fermentation, 'beers'=>$beers, 'yeasts'=>$yeasts, 'selected_beer'=>$selected_beer, 'selected_yeast'=>$selected_yeast, 'selected_alt'=>$selected_alt);
return view('fermentations.edit')->with($data);
}
public function update(Request $request, $id){

2
resources/views/adjunctadditions/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add an Adjunct Addition</h1>
<div>
@if ($errors->any())

2
resources/views/adjunctadditions/edit.blade.php

@ -1,6 +1,6 @@
@extends('adjunctadditions')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12>
<h1 class="display-3">Update Adjunct Addition</h1>
@if ($errors->any())

2
resources/views/adjuncts/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add an Adjunct</h1>
<div>
@if ($errors->any())

2
resources/views/adjuncts/edit.blade.php

@ -1,6 +1,6 @@
@extends('adjuncts')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Adjunct</h1>
@if ($errors->any())

2
resources/views/beers/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add a Beer</h1>
<div>
@if ($errors->any())

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

@ -1,6 +1,6 @@
@extends('beers')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Beer</h1>
@if ($errors->any())

2
resources/views/breweries/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add a brewery</h1>
<div>
@if ($errors->any())

2
resources/views/breweries/edit.blade.php

@ -1,6 +1,6 @@
@extends('breweries')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Brewery</h1>
@if ($errors->any())

2
resources/views/fermentations/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add a Fermentation Step</h1>
<div>
@if ($errors->any())

25
resources/views/fermentations/edit.blade.php

@ -1,6 +1,6 @@
@extends('fermentations')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Fermentation Step</h1>
@if ($errors->any())
@ -17,12 +17,20 @@
@method('PATCH')
@csrf
<div class="form-group">
<label for="beer_id">Beer ID</label>
<input type="text" class="form-control" name="beer_id" value="{{$fermentation->beer_id}}" />
<label for="beer_id">Beer</label>
<select class="form-control" name="beer_id" {{ $selected_beer == $beer->beer_id ? 'selected="selected"' : '' }}>
@foreach ($beers as $beer)
<option value="{{$beer->beer_id}}">{{$beer->name}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="yeast_id">Yeast ID</label>
<input type="text" class="form-control" name="yeast_id" value="{{$fermentation->yeast_id}}" />
<label for="yeast_id">Yeast</label>
<select class="form-control" name="yeast_id" {{ $selected_yeast == $yeast->id ? 'selected="selected"' : '' }}>
@foreach ($yeasts as $yeast)
<option value="{{$yeast->id}}">{{$yeast->name}}</option>
@endforeach
</select>
</div>
<div class="form-group">
<label for="temperature">Temperature</label>
@ -34,7 +42,12 @@
</div>
<div class="form-group">
<label for="alternative">Alternative (ID)</label>
<input type="text" class="form-control" name="alternative" value="{{$fermentation->alternative}}" />
<select class="form-control" name="alternative">
<option value="">None suggested</option>
@foreach ($yeasts as $yeast)
<option value="{{$yeast->id}}" {{ $selected_alt == $yeast->id ? 'selected="selected"' : '' }}>{{$yeast->name}}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-primary">Update</button>
</form>

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

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add a Grain</h1>
<div>
@if ($errors->any())

2
resources/views/grainbills/edit.blade.php

@ -1,6 +1,6 @@
@extends('grainbills')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Grain Bill</h1>
@if ($errors->any())

2
resources/views/grains/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add a Grain</h1>
<div>
@if ($errors->any())

2
resources/views/grains/edit.blade.php

@ -1,6 +1,6 @@
@extends('grains')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Grain</h1>
@if ($errors->any())

2
resources/views/hopadditions/create.blade.php

@ -2,7 +2,7 @@
@section('main')
<div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Add a Hop Addition</h1>
<div>
@if ($errors->any())

2
resources/views/hopadditions/edit.blade.php

@ -1,6 +1,6 @@
@extends('hopadditions')
@section('main') <div class="row">
<div class="col-sm-12 offset-sm-2">
<div class="col-sm-12">
<h1 class="display-3">Update Hop Addition</h1>
@if ($errors->any())

Loading…
Cancel
Save