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. 4
      resources/views/search/results.blade.php

12
app/Http/Controllers/SearchController.php

@ -102,6 +102,18 @@ class SearchController extends Controller
$result['mashes']=$masharr; $result['mashes']=$masharr;
$hopadditions = Hopaddition::where('beer_id', $result->beer_id)->distinct('timing')->get(); $hopadditions = Hopaddition::where('beer_id', $result->beer_id)->distinct('timing')->get();
$result['hopadditions'] = $hopadditions; $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; break;
case('brewerie'): case('brewerie'):

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

@ -113,9 +113,9 @@
@foreach ($results as $result) @foreach ($results as $result)
<tr> <tr>
<td><a href="/beer/{{$result->beer_id}}">{{$result->name}}</a> </td> <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">@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">{{$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> </tr>
@endforeach @endforeach
</div> </div>

Loading…
Cancel
Save