Browse Source

first iteration of search functionality - likely to fail hard

master
jk 3 years ago
parent
commit
6c50229fa1
  1. 4
      app/Http/Controllers/SearchController.php
  2. 2
      resources/views/search/results.blade.php

4
app/Http/Controllers/SearchController.php

@ -47,9 +47,9 @@ class SearchController extends Controller
foreach ($grains as $grain){
$grainname = Grain::where('id', $grain->grain_id)->value('name');
if ($i == 0){
$grainarr[]= array('id'=>$grain->grain_id, 'name'=>$grainname, 'amount'=>$grain->amount, 'grain_bill'=>$grain->grain_bill);
$grainarr[]= array('id'=>$grain->grain_id, 'name'=>$grainname, 'grain_bill'=>$grain->grain_bill);
} else {
array_push($grainarr, array('id'=>$grain->grain_id, 'name'=>$grainname, 'amount'=>$grain->amount, 'grain_bill'=>$grain->grain_bill));
array_push($grainarr, array('id'=>$grain->grain_id, 'name'=>$grainname, 'grain_bill'=>$grain->grain_bill));
};
$i++;
};

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

@ -88,7 +88,7 @@
@foreach ($results as $result)
<tr>
<td><a href="/beer/{{$result->beer_id}}">{{$result->name}}</a> </td>
<td class="hideable">@foreach($result->grains as $grain)<a href="/grain/{{$grain['id']}}">{{$grain['name']}}</a> {{$grain['amount']}}({{$grain['grain_bill']}}%)<br/> @endforeach</td>
<td class="hideable">@foreach($result->grains as $grain)<a href="/grain/{{$grain['id']}}">{{$grain['name']}}</a><span style="float:right;">({{$grain['grain_bill']}}%)</span><br/> @endforeach</td>
<td class="hideable">Hops </td>
<td class="hideable">Yeasts </td>
<td class="hideable">Asjuncts </td>

Loading…
Cancel
Save