1 | <?php |
||
41 | class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract |
||
42 | { |
||
43 | use Authenticatable, Authorizable, CanResetPassword, Notifiable, SearchableTrait; |
||
44 | |||
45 | /** |
||
46 | * The rules for user passwords. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | const PASSWORD_RULES = 'regex:((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})'; |
||
51 | |||
52 | /** |
||
53 | * The regex rules for usernames. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | const USERNAME_RULES = 'regex:/^([\w\d\.\-]{1,255})$/'; |
||
58 | |||
59 | /** |
||
60 | * Level of servers to display when using access() on a user. |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $accessLevel = 'all'; |
||
65 | |||
66 | /** |
||
67 | * The table associated with the model. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $table = 'users'; |
||
72 | |||
73 | /** |
||
74 | * A list of mass-assignable variables. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $fillable = ['username', 'email', 'name_first', 'name_last', 'password', 'language', 'use_totp', 'totp_secret', 'gravatar', 'root_admin']; |
||
79 | |||
80 | /** |
||
81 | * Cast values to correct type. |
||
82 | * |
||
83 | * @var array |
||
84 | */ |
||
85 | protected $casts = [ |
||
86 | 'root_admin' => 'integer', |
||
87 | 'use_totp' => 'integer', |
||
88 | 'gravatar' => 'integer', |
||
89 | ]; |
||
90 | |||
91 | /** |
||
92 | * The attributes excluded from the model's JSON form. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $hidden = ['password', 'remember_token', 'totp_secret']; |
||
97 | |||
98 | /** |
||
99 | * Parameters for search querying. |
||
100 | * |
||
101 | * @var array |
||
102 | */ |
||
103 | protected $searchable = [ |
||
104 | 'columns' => [ |
||
105 | 'email' => 10, |
||
106 | 'username' => 9, |
||
107 | 'name_first' => 6, |
||
108 | 'name_last' => 6, |
||
109 | 'uuid' => 1, |
||
110 | ], |
||
111 | ]; |
||
112 | |||
113 | protected $query; |
||
114 | |||
115 | /** |
||
116 | * Enables or disables TOTP on an account if the token is valid. |
||
117 | * |
||
118 | * @param int $token |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function toggleTotp($token) |
||
131 | |||
132 | /** |
||
133 | * Set a user password to a new value assuming it meets the following requirements: |
||
134 | * - 8 or more characters in length |
||
135 | * - at least one uppercase character |
||
136 | * - at least one lowercase character |
||
137 | * - at least one number. |
||
138 | * |
||
139 | * @param string $password |
||
140 | * @param string $regex |
||
141 | * @return void |
||
142 | */ |
||
143 | public function setPassword($password, $regex = '((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})') |
||
152 | |||
153 | /** |
||
154 | * Send the password reset notification. |
||
155 | * |
||
156 | * @param string $token |
||
157 | * @return void |
||
158 | */ |
||
159 | public function sendPasswordResetNotification($token) |
||
163 | |||
164 | /** |
||
165 | * Return true or false depending on wether the user is root admin or not. |
||
166 | * |
||
167 | * @return bool |
||
168 | */ |
||
169 | public function isRootAdmin() |
||
173 | |||
174 | /** |
||
175 | * Returns the user's daemon secret for a given server. |
||
176 | * |
||
177 | * @param \Pterodactyl\Models\Server $server |
||
178 | * @return null|string |
||
179 | */ |
||
180 | public function daemonToken(Server $server) |
||
190 | |||
191 | /** |
||
192 | * Returns an array of all servers a user is able to access. |
||
193 | * Note: does not account for user admin status. |
||
194 | * |
||
195 | * @return array |
||
196 | */ |
||
197 | public function serverAccessArray() |
||
203 | |||
204 | /** |
||
205 | * Change the access level for a given call to `access()` on the user. |
||
206 | * |
||
207 | * @param string $level can be all, admin, subuser, owner |
||
208 | * @return void |
||
209 | */ |
||
210 | public function setAccessLevel($level = 'all') |
||
219 | |||
220 | /** |
||
221 | * Returns an array of all servers a user is able to access. |
||
222 | * Note: does not account for user admin status. |
||
223 | * |
||
224 | * @param array $load |
||
225 | * @return \Illuiminate\Database\Eloquent\Builder |
||
226 | */ |
||
227 | public function access(...$load) |
||
258 | |||
259 | /** |
||
260 | * Returns all permissions that a user has. |
||
261 | * |
||
262 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
263 | */ |
||
264 | public function permissions() |
||
268 | |||
269 | /** |
||
270 | * Returns all servers that a user owns. |
||
271 | * |
||
272 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
273 | */ |
||
274 | public function servers() |
||
278 | |||
279 | /** |
||
280 | * Return all servers that user is listed as a subuser of directly. |
||
281 | * |
||
282 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
283 | */ |
||
284 | public function subuserOf() |
||
288 | } |
||
289 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: