My beer compendium
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.

47 lines
1.2 KiB

3 years ago
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Models\Mashe;
  5. class MasheController extends Controller
  6. {
  7. public function __construct()
  8. {
  9. $this->middleware('auth');
  10. }
  11. public function index()
  12. {
  13. $project = Mashe::get();
  14. return view('mashes')->with('mashes', $project);
  15. }
  16. public function store(Request $request){
  17. // validation
  18. $this->validate($request,[
  19. 'beer_id' => 'required',
  20. 'temperature' => 'required',
  21. 'duration' => 'required',
  22. 'stage' => 'required',
  23. 'boil' => 'required',
  24. ]);
  25. // create project
  26. $mashes = new Mashe;
  27. $lastID = Mashe::orderBy('id','desc')->value('id');
  28. $mashes->id = number_format($lastID) + 1;
  29. $mashes->beer_id = $request->input('beer_id');
  30. $mashes->temperature = $request->input('temperature');
  31. $mashes->duration = $request->input('duration');
  32. $mashes->stage = $request->input('stage');
  33. $mashes->boil = $request->input('boil');
  34. $mashes->save();
  35. return redirect('/mashes')->with('success', 'Mash Step Added');
  36. }
  37. //
  38. }