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.3 KiB

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