middleware('auth'); } public function index() { $mashes = Mashe::get(); foreach ($mashes as $mash) { $beername = Summarie::where('beer_id', $mash->beer_id)->value('name'); $mash['beer'] = $beername; } return view('mashes.index')->with('mashes', $mashes); } public function store(Request $request){ // validation $this->validate($request,[ 'beer_id' => 'required', 'temperature' => 'required', 'duration' => 'required', 'stage' => 'required', 'boil' => 'required', ]); // create project $mash = new Mashe; $lastID = Mashe::orderBy('id','desc')->take(1)->value('id'); $mash->id = number_format($lastID) + 1; $mash->beer_id = $request->input('beer_id'); $mash->temp = $request->input('temperature'); $mash->duration = $request->input('duration'); $mash->stage = $request->input('stage'); $mash->boil = $request->input('boil'); $mash->save(); return redirect('/mashes')->with('success', 'Mash Step Added!'); } public function edit($id){ $mash = Mashe::where('id', (int)$id)->first(); return view('mashes.edit')->with('mash', $mash); } public function update(Request $request, $id){ // validation $this->validate($request,[ 'beer_id' => 'required', 'temperature' => 'required', 'duration' => 'required', 'stage' => 'required', 'boil' => 'required', ]); $mash = Mashe::where('id', (int)$id)->first(); $mash->beer_id = $request->input('beer_id'); $mash->temp = $request->input('temperature'); $mash->duration = $request->input('duration'); $mash->stage = $request->input('stage'); $mash->boil = $request->input('boil'); $mash->save(); return redirect('/mashs')->with('success', 'Mash Step Updated!'); } public function create() { return view('mashes.create'); } public function destroy($id) { $mash = Mashe::find($id); $mash->delete(); return redirect('/mashes')->with('success', 'Mash Step Deleted!'); } }