AuthController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\User;
  4. use Validator;
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  7. class AuthController extends Controller
  8. {
  9. /*
  10. |--------------------------------------------------------------------------
  11. | Registration & Login Controller
  12. |--------------------------------------------------------------------------
  13. |
  14. | This controller handles the registration of new users, as well as the
  15. | authentication of existing users. By default, this controller uses
  16. | a simple trait to add these behaviors. Why don't you explore it?
  17. |
  18. */
  19. use AuthenticatesAndRegistersUsers;
  20. /**
  21. * Create a new authentication controller instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. $this->middleware('guest', ['except' => 'getLogout']);
  28. }
  29. /**
  30. * Get a validator for an incoming registration request.
  31. *
  32. * @param array $data
  33. * @return \Illuminate\Contracts\Validation\Validator
  34. */
  35. protected function validator(array $data)
  36. {
  37. return Validator::make($data, [
  38. 'name' => 'required|max:255',
  39. 'email' => 'required|email|max:255|unique:users',
  40. 'password' => 'required|confirmed|min:6',
  41. ]);
  42. }
  43. /**
  44. * Create a new user instance after a valid registration.
  45. *
  46. * @param array $data
  47. * @return User
  48. */
  49. protected function create(array $data)
  50. {
  51. return User::create([
  52. 'name' => $data['name'],
  53. 'email' => $data['email'],
  54. 'password' => bcrypt($data['password']),
  55. ]);
  56. }
  57. }