1 | <?php |
||
10 | class UserRequest extends Request |
||
11 | { |
||
12 | |||
13 | protected $method; |
||
14 | |||
15 | /** |
||
16 | * Determine if the user is authorized to make this request. |
||
17 | * |
||
18 | * @return bool |
||
19 | */ |
||
20 | |||
21 | 5 | public function authorize() |
|
25 | |||
26 | /** |
||
27 | * Get the validation rules that apply to the request. |
||
28 | * |
||
29 | * @return array |
||
30 | */ |
||
31 | 6 | public function rules() |
|
32 | { |
||
33 | |||
34 | 6 | $uniqueUser = ''; |
|
35 | 6 | $passwordRules = ''; |
|
36 | 6 | if (Route::getCurrentRoute()->getName() == 'users.create') { |
|
37 | |||
38 | $passwordRules = '|required|min:6'; |
||
39 | $uniqueUser = '|unique:users'; |
||
40 | } |
||
41 | $rules = [ |
||
42 | 6 | 'name' => 'required|max:255', |
|
43 | 6 | 'email' => 'required|email|max:255' . $uniqueUser, |
|
44 | 6 | 'password' => 'confirmed' . $passwordRules, |
|
45 | ]; |
||
46 | 6 | return $rules; |
|
47 | } |
||
48 | |||
49 | |||
50 | 1 | public function store() |
|
51 | { |
||
52 | |||
53 | 1 | $data = $this->except('_token'); |
|
54 | |||
55 | 1 | if ($this->is("users")) { |
|
56 | 1 | $data['provider'] = "created"; |
|
57 | } else { |
||
58 | $data['provider'] = "register"; |
||
59 | } |
||
60 | |||
61 | 1 | $data['provider_id'] = $data['email']; |
|
62 | 1 | $data['verified'] = 1; |
|
63 | |||
64 | 1 | $user = new User; |
|
65 | |||
66 | |||
67 | 1 | $user->fill($data); |
|
68 | 1 | $user->password = bcrypt($this->password); |
|
|
|||
69 | |||
70 | 1 | if (Auth::user()->cannot('store', $user)) { |
|
71 | throw new AuthorizationException(); |
||
72 | } |
||
73 | 1 | return $user->save(); |
|
74 | } |
||
75 | |||
76 | 4 | public function update(User $user) |
|
106 | |||
107 | |||
108 | } |
||
109 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.