RegisterController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 62
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validator() 0 8 1
A create() 0 8 1
1
<?php
2
3
namespace MultiTenantLaravel\App\Http\Controllers\Auth;
4
5
use MultiTenantLaravel\App\Http\Controllers\Controller;
6
use Illuminate\Support\Facades\Hash;
7
use Illuminate\Support\Facades\Validator;
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 registration.
27
         *
28
         * @var string
29
         */
30
        protected $redirectTo = '/home';
31
32
        /**
33
         * Create a new controller instance.
34
         *
35
         * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation 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.

Loading history...
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|string|max:255',
52
                'email' => 'required|string|email|max:255|unique:users',
53
                'password' => 'required|string|min:6|confirmed',
54
            ]);
55
        }
56
57
        /**
58
         * Create a new user instance after a valid registration.
59
         *
60
         * @param  array  $data
61
         * @return \App\User
62
         */
63
        protected function create(array $data)
64
        {
65
            return User::create([
66
                'name' => $data['name'],
67
                'email' => $data['email'],
68
                'password' => Hash::make($data['password']),
69
            ]);
70
        }
71
}
72