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 | * The table associated with the model. |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $table = 'users'; |
||
65 | |||
66 | /** |
||
67 | * A list of mass-assignable variables. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $fillable = ['username', 'email', 'name_first', 'name_last', 'password', 'language', 'use_totp', 'totp_secret', 'gravatar', 'root_admin']; |
||
72 | |||
73 | /** |
||
74 | * Cast values to correct type. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | protected $casts = [ |
||
79 | 'root_admin' => 'integer', |
||
80 | 'use_totp' => 'integer', |
||
81 | 'gravatar' => 'integer', |
||
82 | ]; |
||
83 | |||
84 | /** |
||
85 | * The attributes excluded from the model's JSON form. |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | protected $hidden = ['password', 'remember_token', 'totp_secret']; |
||
90 | |||
91 | /** |
||
92 | * Parameters for search querying. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $searchable = [ |
||
97 | 'columns' => [ |
||
98 | 'email' => 10, |
||
99 | 'username' => 9, |
||
100 | 'name_first' => 6, |
||
101 | 'name_last' => 6, |
||
102 | 'uuid' => 1, |
||
103 | ], |
||
104 | ]; |
||
105 | |||
106 | protected $query; |
||
107 | |||
108 | /** |
||
109 | * Enables or disables TOTP on an account if the token is valid. |
||
110 | * |
||
111 | * @param int $token |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function toggleTotp($token) |
||
124 | |||
125 | /** |
||
126 | * Set a user password to a new value assuming it meets the following requirements: |
||
127 | * - 8 or more characters in length |
||
128 | * - at least one uppercase character |
||
129 | * - at least one lowercase character |
||
130 | * - at least one number. |
||
131 | * |
||
132 | * @param string $password |
||
133 | * @param string $regex |
||
134 | * @return void |
||
135 | */ |
||
136 | public function setPassword($password, $regex = '((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,})') |
||
145 | |||
146 | /** |
||
147 | * Send the password reset notification. |
||
148 | * |
||
149 | * @param string $token |
||
150 | * @return void |
||
151 | */ |
||
152 | public function sendPasswordResetNotification($token) |
||
156 | |||
157 | /** |
||
158 | * Return true or false depending on wether the user is root admin or not. |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | public function isRootAdmin() |
||
166 | |||
167 | /** |
||
168 | * Returns the user's daemon secret for a given server. |
||
169 | * |
||
170 | * @param \Pterodactyl\Models\Server $server |
||
171 | * @return null|string |
||
172 | */ |
||
173 | public function daemonToken(Server $server) |
||
187 | |||
188 | /** |
||
189 | * Returns an array of all servers a user is able to access. |
||
190 | * Note: does not account for user admin status. |
||
191 | * |
||
192 | * @return array |
||
193 | */ |
||
194 | public function serverAccessArray() |
||
200 | |||
201 | /** |
||
202 | * Returns an array of all servers a user is able to access. |
||
203 | * Note: does not account for user admin status. |
||
204 | * |
||
205 | * @param array $load |
||
206 | * @return \Illuiminate\Database\Eloquent\Builder |
||
207 | */ |
||
208 | public function access(...$load) |
||
222 | |||
223 | /** |
||
224 | * Returns all permissions that a user has. |
||
225 | * |
||
226 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
227 | */ |
||
228 | public function permissions() |
||
232 | |||
233 | /** |
||
234 | * Returns all servers that a user owns. |
||
235 | * |
||
236 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
237 | */ |
||
238 | public function servers() |
||
242 | } |
||
243 |
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.