From 3ab8c879cc45d386e91ff04a4638f15adab4feb3 Mon Sep 17 00:00:00 2001 From: jk Date: Thu, 24 Jun 2021 14:44:06 +0100 Subject: [PATCH] first iteration of search functionality - likely to fail hard --- app/Http/Controllers/SearchController.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 72da383..c46c4f7 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -43,13 +43,12 @@ class SearchController extends Controller $i++; }; $grains = Grainbill::where('beer_id', $result->beer_id)->distinct('grain_id'); - $result['grains']=[]; + $result['grains'][]=[]; $i = 0; foreach ($grains as $grain){ $grainname = Grain::where('id', $grain->id)->value('name'); - $result['grains'][$i]['id'] = $grain->id; - $result['grains'][$i]['name'] = $grainname; - $i++; + $grainarr = array('id'=>$grain->id, 'name'=>$grainname); + array_push($result['grains'],$grainarr); }; $yeasts = Fermentation::where('beer_id', $result->beer_id)->distinct('yeast_id'); $result['yeasts']=[];