Browse Source

first iteration of search functionality - likely to fail hard

master
jk 3 years ago
parent
commit
998b6fe745
  1. 12
      app/Http/Controllers/SearchController.php
  2. 2
      resources/views/search/results.blade.php

12
app/Http/Controllers/SearchController.php

@ -102,6 +102,18 @@ class SearchController extends Controller
$result['mashes']=$masharr;
$hopadditions = Hopaddition::where('beer_id', $result->beer_id)->distinct('timing')->get();
$result['hopadditions'] = $hopadditions;
$fermentations = Fermentation::where('beer_id', $result->beer_id)-get();
$fermentarr = array();
$i = 0;
foreach ($fermentations as $fermentation){
if ($i == 0){
$fermentarr = array('stage'=>($i + 1), 'temp'=>$fermentation->temperature, 'duration'=>$fermentation->duration);
} else {
array_push($fermentarr, array('stage'=>($i + 1), 'temp'=>$fermentation->temperature, 'duration'=>$fermentation->duration));
};
$i++;
};
$result['fermentations'] = $fermentarr;
}
break;
case('brewerie'):

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

@ -115,7 +115,7 @@
<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 @endif<br/> @endforeach</td>
<td class="hideable">{{$result->boil}}m boil with hop additions at: <br/> @foreach($result->hopadditions as $hopaddition) {{$hopaddition->timing}} @endforeach</td>
<td class="hideable">Fermentation stuff</td>
<td class="hideable">@foreach($result->fermentations as $fermentation)Stage: {{$fermentation['stage']}}, {{$fermentation['temp']}}°C @if($fermentation['duration'])note: {{$fermenation['duration']}}@endif @endforeach </td>
</tr>
@endforeach
</div>

Loading…
Cancel
Save