middleware('auth'); } public function index($adjunctID) { $adjunct = Adjunct::where('id', $adjunctID)->first(); $adjunctadditions = Adjunctaddition::where('adjunct_id', $adjunctID)->distinct('beer_id')->get(); foreach ($adjunctadditions as $adjuncts) { $beerName = DB::table('summaries')->where('beer_id', $adjuncts->beer_id)->value('name'); $breweryID = DB::table('summaries')->where('beer_id', $adjuncts->beer_id)->value('brewery_id'); $breweryName = DB::table('breweries')->where('id', $breweryID)->value('name'); $adjuncts['beer'] = $beerName; $adjuncts['breweryID'] = $breweryID; $adjuncts['brewery']=$breweryName; } $adjunctadditions = $adjunctadditions->sortBy('brewery'); $data = array('adjunct'=>$adjunct, 'adjunctadditions'=>$adjunctadditions); return view('adjunct')->with($data); } }