middleware('auth'); } public function index($hopID) { $hop = DB::table('hops')->where('id', $hopID)->first(); $hopadditions = Hopaddition::where('hop_id', $hopID)->distinct('beer_id')->get(); foreach ($hopadditions as $hops) { $beerName = DB::table('summaries')->where('beer_id', $hops->beer_id)->value('name'); $breweryID = DB::table('summaries')->where('beer_id', $hops->beer_id)->value('brewery_id'); $breweryName = DB::table('breweries')->where('id', $breweryID)->value('name'); $hops['beer'] = $beerName; $hops['breweryID'] = $breweryID; $hops['brewery']=$breweryName; } $hopadditions = $hopadditions->sortBy('brewery'); $data = array('hop'=>$hop, 'hopadditions'=>$hopadditions); return view('hop')->with($data); } }