Advertisement
Guest User

Untitled

a guest
Feb 28th, 2021
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Auth;
  4.  
  5. use App\User;
  6. use App\Http\Controllers\Controller;
  7. use Illuminate\Support\Facades\Validator;
  8. use Illuminate\Foundation\Auth\RegistersUsers;
  9.  
  10. class RegisterController extends Controller
  11. {
  12. /*
  13. |--------------------------------------------------------------------------
  14. | Register Controller
  15. |--------------------------------------------------------------------------
  16. |
  17. | This controller handles the registration of new users as well as their
  18. | validation and creation. By default this controller uses a trait to
  19. | provide this functionality without requiring any additional code.
  20. |
  21. */
  22.  
  23. use RegistersUsers;
  24.  
  25. /**
  26. * Where to redirect users after registration.
  27. *
  28. * @var string
  29. */
  30. protected $redirectTo = '/';
  31.  
  32. protected $username = 'login';
  33.  
  34. /**
  35. * Create a new controller instance.
  36. *
  37. * @return void
  38. */
  39. public function __construct()
  40. {
  41. $this->middleware('guest');
  42. }
  43.  
  44. /**
  45. * Get a validator for an incoming registration request.
  46. *
  47. * @param array $data
  48. * @return \Illuminate\Contracts\Validation\Validator
  49. */
  50. protected function validator(array $data)
  51. {
  52. return Validator::make($data, [
  53. 'name' => 'required|max:255',
  54. 'login' => 'required|max:255|unique:users,login',
  55. 'email' => 'required|email|max:255|unique:users',
  56. 'password' => 'required|min:6|confirmed',
  57.  
  58. ]);
  59. }
  60.  
  61. /**
  62. * Create a new user instance after a valid registration.
  63. *
  64. * @param array $data
  65. * @return User
  66. */
  67. protected function create(array $data)
  68. {
  69. return User::create([
  70. 'name' => $data['name'],
  71. 'login' => $data['login'],
  72. 'email' => $data['email'],
  73. 'password' => bcrypt($data['password']),
  74. ]);
  75. }
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement