middleware('auth'); } public function index($yeastID) { $yeast = DB::table('yeasts')->where('id', $yeastID)->first(); $yeastadditions = Fermentation::where('yeast_id', $yeastID)->distinct('beer_id')->get(); foreach ($yeastadditions as $yeasts) { $beerName = DB::table('summaries')->where('beer_id', $yeasts->beer_id)->value('name'); $breweryID = DB::table('summaries')->where('beer_id', $yeasts->beer_id)->value('brewery_id'); $breweryName = DB::table('breweries')->where('id', $breweryID)->value('name'); if($yeasts->alternative) { $altname = DB::table('yeasts')->where('id', $yeasts->alternative)->value('name'); $yeasts['altname']=$altname; } $yeasts['beer'] = $beerName; $yeasts['breweryID'] = $breweryID; $yeasts['brewery']=$breweryName; } $yeastadditions = $yeastadditions->sortBy('brewery'); $data = array('yeast'=>$yeast, 'yeastadditions'=>$yeastadditions); return view('yeast')->with($data); } }