middleware('auth'); } public function index() { $project = Hop::orderBy('name')->get(); return view('hops')->with('hops', $project); } public function store(Request $request){ // validation $this->validate($request,[ 'name' => 'required', ]); // create project $hop = new hop; $lastID = Hop::orderBy('id','desc')->value('id'); $hop->id = number_format($lastID) + 1; $hop->name = $request->input('name'); if ($request->input('alpha_acid')) { $hop->alpha_acid = $request->input('alpha_acid'); } $hop->bitter = $request->input('bitter'); $hop->aroma = $request->input('aroma'); if ($request->input('beta_acid')) { $hop->beta_acid = $request->input('beta_acid'); } if ($request->input('myrcene')) { $hop->myrcene = $request->input('myrcene'); } if ($request->input('profile')) { $hop->profile = '{'.$request->input('profile').'}'; } if ($request->input('humulene')) { $hop->humulene = $request->input('humulene'); } if ($request->input('total_oil')) { $hop->total_oil = $request->input('total_oil'); } if ($request->input('cohumulone')) { $hop->cohumulone = $request->input('cohumulone'); } if ($request->input('farnesene')) { $hop->farnesene = $request->input('farnesene'); } if ($request->input('caryophyllene')) { $hop->caryophyllene = $request->input('caryophyllene'); } $hop->save(); return redirect('/hops')->with('success', 'Hop Added'); } }