RegisterController::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Gameap\Http\Controllers\Auth;
4
5
use Gameap\Http\Controllers\Controller;
6
use Gameap\Models\User;
7
use Illuminate\Foundation\Auth\RegistersUsers;
8
use Illuminate\Support\Facades\Validator;
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 = '/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
            'login'    => 'required|string|max:255|unique:users',
52
            'email'    => 'required|string|email|max:255|unique:users',
53
            'password' => 'required|string|min:6|confirmed',
54
            'name'     => 'string|max:255',
55
56
            'g-recaptcha-response' => env('GOOGLE_RECAPTCHA_SECRET')
57
                ? 'required|recaptcha'
58
                : '',
59
        ]);
60
    }
61
62
    /**
63
     * Create a new user instance after a valid registration.
64
     *
65
     * @param  array  $data
66
     * @return \Gameap\Models\User
67
     */
68
    protected function create(array $data)
69
    {
70
        return User::create([
71
            'login' => $data['login'],
72
            'email' => $data['email'],
73
            // 'password' => bcrypt($data['password'])
74
            'password' => $data['password'],
75
        ]);
76
    }
77
}
78