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.

39 lines
908 B

3 years ago
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\Leann;
  5. class LeannController extends Controller
  6. {
  7. public function __construct()
  8. {
  9. $this->middleware('auth');
  10. }
  11. public function index()
  12. {
  13. $project = Leann::where('user_id', auth()->user()->id)->get();
  14. return view('home')->with('projects', $project);
  15. }
  16. public function store(Request $request){
  17. // validation
  18. $this->validate($request,[
  19. 'project_name' => 'required',
  20. 'description' => 'required'
  21. ]);
  22. // create project
  23. $project = new Leann;
  24. $project->name = $request->input('project_name');
  25. $project->description = $request->input('description');
  26. $project->user_id = auth()->user()->id;
  27. $project->save();
  28. return redirect('/home')->with('success', 'Project Added');
  29. }
  30. }