Issues (73)

src/Controllers/Auth/RegisterController.php (5 issues)

1
<?php
2
3
namespace Chuckbe\Chuckcms\Controllers\Auth;
4
5
use Chuckbe\Chuckcms\Chuck\UserRepository;
6
use Chuckbe\Chuckcms\Models\User;
7
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
8
use Illuminate\Foundation\Auth\RegistersUsers;
0 ignored issues
show
The type Illuminate\Foundation\Auth\RegistersUsers was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Illuminate\Foundation\Bus\DispatchesJobs;
10
use Illuminate\Foundation\Validation\ValidatesRequests;
11
use Illuminate\Routing\Controller as BaseController;
12
use Illuminate\Support\Facades\Validator;
13
14
class RegisterController extends BaseController
15
{
16
    /*
17
    |--------------------------------------------------------------------------
18
    | Register Controller
19
    |--------------------------------------------------------------------------
20
    |
21
    | This controller handles the registration of new users as well as their
22
    | validation and creation. By default this controller uses a trait to
23
    | provide this functionality without requiring any additional code.
24
    |
25
    */
26
27
    use AuthorizesRequests;
28
    use DispatchesJobs;
29
    use ValidatesRequests;
30
    use RegistersUsers;
31
32
    /**
33
     * Where to redirect users after registration.
34
     *
35
     * @var string
36
     */
37
    protected $redirectTo = '/dashboard';
38
39
    protected function redirectTo()
40
    {
41
        return '/'.Auth::user()->roles()->first()->redirect;
0 ignored issues
show
The type Chuckbe\Chuckcms\Controllers\Auth\Auth was not found. Did you mean Auth? If so, make sure to prefix the type with \.
Loading history...
42
    }
43
44
    /**
45
     * User Repository.
46
     *
47
     * @var string
48
     */
49
    private $userRepository;
50
51
    /**
52
     * Create a new controller instance.
53
     *
54
     * @return void
55
     */
56
    public function __construct(UserRepository $userRepository)
57
    {
58
        $this->userRepository = $userRepository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $userRepository of type Chuckbe\Chuckcms\Chuck\UserRepository is incompatible with the declared type string of property $userRepository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
59
        $this->middleware('guest');
60
    }
61
62
    public function showRegistrationForm()
63
    {
64
        return view('chuckcms::auth.register');
65
    }
66
67
    /**
68
     * Get a validator for an incoming registration request.
69
     *
70
     * @param array $data
71
     *
72
     * @return \Illuminate\Contracts\Validation\Validator
73
     */
74
    protected function validator(array $data)
75
    {
76
        return Validator::make($data, [
77
            'name'     => 'required|string|max:255',
78
            'email'    => 'required|string|email|max:255|unique:users',
79
            'password' => 'required|string|min:6|confirmed',
80
        ]);
81
    }
82
83
    /**
84
     * Create a new user instance after a valid registration.
85
     *
86
     * @param array $data
87
     *
88
     * @return \App\User
0 ignored issues
show
The type App\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
89
     */
90
    protected function create(array $data)
91
    {
92
        return User::create([
0 ignored issues
show
Bug Best Practice introduced by
The expression return Chuckbe\Chuckcms\...oken(), 'active' => 1)) also could return the type Chuckbe\Chuckcms\Models\User which is incompatible with the documented return type App\User.
Loading history...
93
            'name'     => $data['name'],
94
            'email'    => $data['email'],
95
            'password' => bcrypt($data['password']),
96
            'token'    => $this->userRepository->createToken(),
97
            'active'   => 1,
98
        ]);
99
    }
100
}
101