1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Colligator\Http\Controllers\Auth; |
4
|
|
|
|
5
|
|
|
use Colligator\Http\Controllers\Controller; |
6
|
|
|
use Colligator\User; |
7
|
|
|
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; |
8
|
|
|
use Validator; |
9
|
|
|
|
10
|
|
|
class AuthController extends Controller |
11
|
|
|
{ |
12
|
|
|
/* |
13
|
|
|
|-------------------------------------------------------------------------- |
14
|
|
|
| Registration & Login Controller |
15
|
|
|
|-------------------------------------------------------------------------- |
16
|
|
|
| |
17
|
|
|
| This controller handles the registration of new users, as well as the |
18
|
|
|
| authentication of existing users. By default, this controller uses |
19
|
|
|
| a simple trait to add these behaviors. Why don't you explore it? |
20
|
|
|
| |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
use AuthenticatesAndRegistersUsers; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Create a new authentication controller instance. |
27
|
|
|
*/ |
28
|
|
|
public function __construct() |
29
|
|
|
{ |
30
|
|
|
$this->middleware('guest', ['except' => 'getLogout']); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get a validator for an incoming registration request. |
35
|
|
|
* |
36
|
|
|
* @param array $data |
37
|
|
|
* |
38
|
|
|
* @return \Illuminate\Contracts\Validation\Validator |
39
|
|
|
*/ |
40
|
|
|
protected function validator(array $data) |
41
|
|
|
{ |
42
|
|
|
return Validator::make($data, [ |
43
|
|
|
'name' => 'required|max:255', |
44
|
|
|
'email' => 'required|email|max:255|unique:users', |
45
|
|
|
'password' => 'required|confirmed|min:6', |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create a new user instance after a valid registration. |
51
|
|
|
* |
52
|
|
|
* @param array $data |
53
|
|
|
* |
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
|
|
|
} |
65
|
|
|
|