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