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