|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pterodactyl\Http\Controllers\Auth; |
|
4
|
|
|
|
|
5
|
|
|
use Validator; |
|
6
|
|
|
use Pterodactyl\User; |
|
7
|
|
|
use Pterodactyl\Http\Controllers\Controller; |
|
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 login / registration. |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $redirectTo = '/home'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Create a new controller instance. |
|
34
|
|
|
* |
|
35
|
|
|
* @return void |
|
|
|
|
|
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->middleware('guest'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Get a validator for an incoming registration request. |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $data |
|
46
|
|
|
* @return \Illuminate\Contracts\Validation\Validator |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function validator(array $data) |
|
49
|
|
|
{ |
|
50
|
|
|
return Validator::make($data, [ |
|
51
|
|
|
'name' => 'required|max:255', |
|
52
|
|
|
'email' => 'required|email|max:255|unique:users', |
|
53
|
|
|
'password' => 'required|min:6|confirmed', |
|
54
|
|
|
]); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Create a new user instance after a valid registration. |
|
59
|
|
|
* |
|
60
|
|
|
* @param array $data |
|
61
|
|
|
* @return User |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function create(array $data) |
|
64
|
|
|
{ |
|
65
|
|
|
return User::create([ |
|
66
|
|
|
'name' => $data['name'], |
|
67
|
|
|
'email' => $data['email'], |
|
68
|
|
|
'password' => bcrypt($data['password']), |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.