You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							36 lines
						
					
					
						
							1.1 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							36 lines
						
					
					
						
							1.1 KiB
						
					
					
				| <?php | |
| 
 | |
| namespace App\Http\Controllers; | |
| 
 | |
| use Illuminate\Http\Request; | |
| use App\Models\Hop; | |
| use App\Models\Hopaddition; | |
| use Illuminate\Support\Facades\DB; | |
| 
 | |
| class HopcardController extends Controller | |
| { | |
|     public function __construct() | |
|     { | |
|         $this->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); | |
|     } | |
| 
 | |
| }
 |