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.

41 lines
858 B

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