daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest May 16th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Http\Controllers\Auth;
  4.  
  5. use App\Notifications\NewUser;
  6. use App\User;
  7. use App\Http\Controllers\Controller;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Facades\Validator;
  10. use Illuminate\Foundation\Auth\RegistersUsers;
  11.  
  12. class RegisterController extends Controller
  13. {
  14.     /*
  15.     |--------------------------------------------------------------------------
  16.     | Register Controller
  17.     |--------------------------------------------------------------------------
  18.     |
  19.     | This controller handles the registration of new users as well as their
  20.     | validation and creation. By default this controller uses a trait to
  21.     | provide this functionality without requiring any additional code.
  22.     |
  23.     */
  24.  
  25.     use RegistersUsers;
  26.  
  27.     /**
  28.      * Where to redirect users after registration.
  29.      *
  30.      * @var string
  31.      */
  32.     protected $redirectTo = 'member/dashboard';
  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.             'email' => 'required|email|max:255|unique:users',
  55.             'password' => 'required|min:6|confirmed',
  56.         ]);
  57.     }
  58.  
  59.     /**
  60.      * Create a new user instance after a valid registration.
  61.      *
  62.      * @param  array  $data
  63.      * @return User
  64.      */
  65.     protected function create(array $data)
  66.     {
  67.         return User::create([
  68.             'name' => $data['name'],
  69.             'email' => $data['email'],
  70.             'password' => bcrypt($data['password']),
  71.         ]);
  72.     }
  73.  
  74.     /**
  75.      * The user has been registered.
  76.      *
  77.      * @param  \Illuminate\Http\Request  $request
  78.      * @param  mixed  $user
  79.      * @return mixed
  80.      */
  81.     protected function registered(Request $request, $user)
  82.     {
  83.         //send welcome email notification
  84.         $user->notify(new NewUser($user));
  85.         $user->attachRole(2);
  86.  
  87.     }
  88. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top