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.
40 lines
1.3 KiB
40 lines
1.3 KiB
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Models\Yeast;
|
|
use App\Models\Fermentation;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class YeastcardController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->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);
|
|
}
|
|
|
|
}
|