AuthController.php 1.7 KB

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