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.2 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							36 lines
						
					
					
						
							1.2 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Http\Controllers;
							 | 
						|
								
							 | 
						|
								use Illuminate\Http\Request;
							 | 
						|
								use App\Models\Grain;
							 | 
						|
								use App\Models\Grainbill;
							 | 
						|
								use Illuminate\Support\Facades\DB;
							 | 
						|
								
							 | 
						|
								class GraincardController extends Controller
							 | 
						|
								{
							 | 
						|
								    public function __construct()
							 | 
						|
								    {
							 | 
						|
								        $this->middleware('auth');
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    public function index($grainID)
							 | 
						|
								    {
							 | 
						|
									$grain = DB::table('grains')->where('id', $grainID)->first();
							 | 
						|
								        $grainadditions = Grainbill::where('grain_id', $grainID)->distinct('beer_id')->get();
							 | 
						|
								        foreach ($grainadditions as $grains)
							 | 
						|
								        {
							 | 
						|
								                $beerName = DB::table('summaries')->where('beer_id', $grains->beer_id)->value('name');
							 | 
						|
								                $breweryID = DB::table('summaries')->where('beer_id', $grains->beer_id)->value('brewery_id');
							 | 
						|
								                $breweryName = DB::table('breweries')->where('id', $breweryID)->value('name');
							 | 
						|
								                $grains['beer'] = $beerName;
							 | 
						|
								                $grains['breweryID'] = $breweryID;
							 | 
						|
								                $grains['brewery']=$breweryName;
							 | 
						|
								        }
							 | 
						|
								        $grainadditions = $grainadditions->sortBy('brewery');
							 | 
						|
								        $data = array('grain'=>$grain, 'grainadditions'=>$grainadditions);
							 | 
						|
								        return view('grain')->with($data);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								}
							 |