middleware('auth'); } public function index() { $yeasts = Yeast::orderBy('name')->get(); return view('yeasts.index')->with('yeasts', $yeasts); } public function store(Request $request){ // validation $this->validate($request,[ 'name' => 'required', ]); // create project $yeast = new Yeast; $lastID = Yeast::orderBy('id','desc')->take(1)->value('id'); $yeast->id = number_format($lastID) + 1; $yeast->name = $request->input('name'); if ($request->input('attenuation')) { $yeast->attenuation = $request->input('attenuation'); } if ($request->input('flocculation')) { $yeast->flocculation = $request->input('flocculation'); } if ($request->input('profile')) { $yeast->profile = '{'.$request->input('profile').'}'; } if ($request->input('tolerance')) { $yeast->tolerance = $request->input('tolerance'); } if ($request->input('temp_range')) { $yeast->temp_range = $request->input('temp_range'); } $yeast->save(); return redirect('/yeasts')->with('success', 'Yeast Added!'); } public function edit($id){ $yeast = Yeast::where('id', (int)$id)->first(); return view('yeasts.edit')->with('yeast', $yeast); } public function update(Request $request, $id){ // validation $this->validate($request,[ 'name' => 'required', ]); $yeast = Yeast::where('id', (int)$id)->first(); $yeast->name = $request->input('name'); if ($request->input('attenuation')) { $yeast->attenuation = $request->input('attenuation'); } if ($request->input('flocculation')) { $yeast->flocculation = $request->input('flocculation'); } if ($request->input('profile')) { $yeast->profile = '{'.$request->input('profile').'}'; } if ($request->input('tolerance')) { $yeast->tolerance = $request->input('tolerance'); } if ($request->input('temp_range')) { $yeast->temp_range = $request->input('temp_range'); } $yeast->save(); return redirect('/yeasts')->with('success', 'Yeast Updated!'); } public function create() { return view('yeasts.create'); } public function destroy($id) { $yeast = Yeast::find($id); $yeast->delete(); return redirect('/yeasts')->with('success', 'Yeast deleted!'); } }