You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.9 KiB

  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\User;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Support\Facades\Validator;
  6. use Illuminate\Foundation\Auth\RegistersUsers;
  7. class RegisterController extends Controller
  8. {
  9. /*
  10. |--------------------------------------------------------------------------
  11. | Register Controller
  12. |--------------------------------------------------------------------------
  13. |
  14. | This controller handles the registration of new users as well as their
  15. | validation and creation. By default this controller uses a trait to
  16. | provide this functionality without requiring any additional code.
  17. |
  18. */
  19. use RegistersUsers;
  20. /**
  21. * Where to redirect users after registration.
  22. *
  23. * @var string
  24. */
  25. protected $redirectTo = '/dashboard';
  26. /**
  27. * Create a new controller instance.
  28. *
  29. * @return void
  30. */
  31. public function __construct()
  32. {
  33. $this->middleware('auth'); // disable registration
  34. #$this->middleware('guest'); // allow registration
  35. }
  36. /**
  37. * Get a validator for an incoming registration request.
  38. *
  39. * @param array $data
  40. * @return \Illuminate\Contracts\Validation\Validator
  41. */
  42. protected function validator(array $data)
  43. {
  44. return Validator::make($data, [
  45. 'name' => 'required|string|max:255',
  46. 'email' => 'required|string|email|max:255|unique:users',
  47. 'password' => 'required|string|min:6|confirmed',
  48. ]);
  49. }
  50. /**
  51. * Create a new user instance after a valid registration.
  52. *
  53. * @param array $data
  54. * @return User
  55. */
  56. protected function create(array $data)
  57. {
  58. return User::create([
  59. 'name' => $data['name'],
  60. 'email' => $data['email'],
  61. 'password' => bcrypt($data['password']),
  62. ]);
  63. }
  64. }