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.
		
		
		
		
		
			
		
			
				
					
					
						
							48 lines
						
					
					
						
							1.3 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							48 lines
						
					
					
						
							1.3 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\Http\Controllers;
							 | 
						|
								
							 | 
						|
								use Illuminate\Http\Request;
							 | 
						|
								use App\Models\Fermentation;
							 | 
						|
								class FermentationController extends Controller
							 | 
						|
								{
							 | 
						|
								    public function __construct()
							 | 
						|
								    {
							 | 
						|
								        $this->middleware('auth');
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    public function index()
							 | 
						|
								    {
							 | 
						|
								        $project = Fermentation::get();
							 | 
						|
								        return view('fermentations')->with('fermentations', $project);
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								   public function store(Request $request){
							 | 
						|
								        // validation
							 | 
						|
								        $this->validate($request,[
							 | 
						|
								            'beer_id' => 'required',
							 | 
						|
								            'yeast_id' => 'required',
							 | 
						|
								            'temperature' => 'required',
							 | 
						|
								            'duration' => 'required',
							 | 
						|
								        ]);
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								        // create project
							 | 
						|
								        $yeast = new Fermentations;
							 | 
						|
								        $lastID = Fermentations::orderBy('id','desc')->value('id');
							 | 
						|
								        $yeast->id = number_format($lastID) + 1;
							 | 
						|
								        $yeast->beer_id = $request->input('beer_id');
							 | 
						|
								        $yeast->yeast_id = $request->input('yeast_id');
							 | 
						|
								        $yeast->temperature = $request->input('temperature');
							 | 
						|
								        $yeast->duration = $request->input('duration');
							 | 
						|
									if ($request->input('alternative'))
							 | 
						|
									{
							 | 
						|
								        	$yeast->alternative = $request->input('alternative');
							 | 
						|
									}
							 | 
						|
								        $yeast->save();
							 | 
						|
								
							 | 
						|
								        return redirect('/fermnentations')->with('success', 'Fermentation Step Added');
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								}
							 |