RegistrationController.php 888 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Requests\RegistrationForm;
  4. use App\Mail\Welcome;
  5. use Illuminate\Session\SessionManager;
  6. use Illuminate\Session\Store;
  7. class RegistrationController extends Controller
  8. {
  9. public function create()
  10. {
  11. return view('registration.create');
  12. }
  13. /**
  14. * Submitted data validation:
  15. * - now in RegistrationRequest::rules().
  16. * - the code in this method won't be run if validation fails.
  17. * - validation is found by Reflection on the method type hint.
  18. */
  19. public function store(RegistrationForm $request)
  20. {
  21. $user = $request->persist();
  22. // Sign user in.
  23. auth()->login($user);
  24. \Mail::to($user)->send(new Welcome($user));
  25. $session = session();
  26. $session->flash('message', 'Thanks so much for signing up.');
  27. return redirect()->home();
  28. }
  29. }