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){ foreach ($grains as $grain){
$grainname = Grain::where('id', $grain->grain_id)->value('name'); $grainname = Grain::where('id', $grain->grain_id)->value('name');
if ($i == 0){ 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 { } 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++; $i++;
}; };

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

@ -88,7 +88,7 @@
@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->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">Hops </td>
<td class="hideable">Yeasts </td> <td class="hideable">Yeasts </td>
<td class="hideable">Asjuncts </td> <td class="hideable">Asjuncts </td>

Loading…
Cancel
Save