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
|
|||
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
|
|||
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; |
||
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. 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
|
|||
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 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths