RegistrationController.php 1003 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\User;
  4. use Illuminate\Http\Request;
  5. class RegistrationController extends Controller
  6. {
  7. public function create()
  8. {
  9. return view('registration.create');
  10. }
  11. public function store(Request $request)
  12. {
  13. // Validate submitted data.
  14. $this->validate($request, [
  15. 'name' => 'required',
  16. 'email' => 'required|email',
  17. // "confirmed" uses <field>_confirmation.
  18. 'password' => 'required|confirmed',
  19. ]);
  20. // Create user. This would give us a clear password.
  21. // $user = User::create($request->only(['name', 'email', 'password']));
  22. $user = User::create([
  23. 'name' => $request->get('name'),
  24. 'email' => $request->get('email'),
  25. 'password' => bcrypt($request->get('password')),
  26. ]);
  27. // Sign user in.
  28. auth()->login($user);
  29. // Redirect to home page.
  30. return redirect()->home();
  31. }
  32. }