middleware('auth'); } public function index($beerID) { $beer = DB::table('summaries')->where('beer_id', $beerID)->first(); $breweries = Brewerie::where('id', $beer->brewery_id)->get(); $grainbills = Grainbill::where('beer_id', $beerID)->get(); foreach($grainbills as $grain) { $grainname = DB::table('grains')->where('id', $grain->grain_id)->first(); $grain['grain_name'] = $grainname->name; }; $mashsteps = Mashe::where('beer_id', $beerID)->get(); $hopadditions = Hopaddition::where('beer_id', $beerID)->get(); foreach($hopadditions as $hop) { $hopname = DB::table('hops')->where('id', $hop->hop_id)->first(); $hop['hop_name'] = $hopname->name; }; $yeastadditions = Fermentation::where('beer_id', $beerID)->get(); foreach($yeastadditions as $yeast) { $yeastname = DB::table('yeasts')->where('id', $yeast->yeast_id)->first(); $yeast['yeast_name'] = $yeastname->name; if($yeast->alternative) { $altname = DB::table('yeasts')->where('id', $yeast->alternative)->value('name'); $yeast['altname'] = $altname; } }; $adjunctadditions = Adjunctaddition::where('beer_id', $beerID)->get(); foreach($adjunctadditions as $adjunct) { $adjunctname = DB::table('adjuncts')->where('id', $adjunct->adjunct_id)->first(); $adjunct['adjunct_name'] = $adjunctname->name; }; $data = array('breweries'=>$breweries, 'beer'=>$beer, 'grainbills'=>$grainbills, 'mashsteps'=>$mashsteps, 'hopadditions'=>$hopadditions, 'adjunctadditions'=>$adjunctadditions, 'yeastadditions'=>$yeastadditions); return view('beer')->with($data); } }