Browse Source

first iteration of search functionality - likely to fail hard

master
jk 3 years ago
parent
commit
a8605e154f
  1. 16
      app/Http/Controllers/SearchController.php
  2. 25
      resources/views/search/results.blade.php

16
app/Http/Controllers/SearchController.php

@ -85,6 +85,22 @@ class SearchController extends Controller
$i++;
};
$result['adjuncts']=$adjunctarr;
$mashes = Mashe::where('beer_id', $result->beer_id)->get();
$masharr = array();
$i = 0;
foreach ($mashes as $mash){
if ($mash->stage == 1) {
$result->boil = $mash->boil;
}
if ($i == 0){
$masharr[] = array('id'=>$mash->id, 'stage'=>$mash->stage, 'duration'=>$mash->duration);
} else {
array_push($masharr, array('id'=>$mash->id, 'stage'=>$mash->stage, 'duration'=>$mash->duration));
};
$i++;
};
$results['mashes']=$masharr;
$hopadditions = Hopaddition::where('beer_id', $result->beer_id)->distinct('timing')->get();
}
break;
case('brewerie'):

25
resources/views/search/results.blade.php

@ -65,7 +65,7 @@
<td class="hideable">{{$result->ibu}} </td>
<td class="hideable">{{$result->ebc}} </td>
<td class="hideable">{{$result->srm}} </td>
<td class="hideable">{{$result->pH}} </td>
<td class="hideable">{{$result->ph}} </td>
</tr>
@endforeach
</tbody>
@ -97,7 +97,28 @@
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane fade" id="processes" aria-labelledby="processes-tab"></div>
<div role="tabpanel" class="tab-pane fade" id="processes" aria-labelledby="processes-tab">
<table class="table table-striped table-dark" id="table-programs">
<!-- This piece of code is for error messages display purposes -->
@include('inc.messages')
<thead>
<tr>
<th scope="col">@sortablelink('name', 'Beer')</th>
<th scope="col">Mash</th>
<th scope="col" class="hideable">Hop Additions</th>
<th scope="col" class="hideable">Fermentation</th>
</tr>
</thead>
<tbody>
@foreach ($results as $result)
<tr>
<td><a href="/beer/{{$result->beer_id}}">{{$result->name}}</a> </td>
<td class="hideable">@foreach{{$result->mashes as $mash)Stage: {{$mash['stage']}} at {{$mash['temp']}}°C @if($mash['duration'])for {{$mash['duration']}}m@endforeach</td>
<td class="hideable">{{$result->boil}}m boil with hop additions at @foreach($result->hopadditions as $hopaddition) {{$hopaddition->timing}} @endforeach</td>
<td class="hideable">Fermentation stuff</td>
</tr>
@endforeach
</div>
</div>
@endif
</div>

Loading…
Cancel
Save