1 | <?php |
||
36 | class Server extends Model |
||
37 | { |
||
38 | use Notifiable, SearchableTrait; |
||
39 | |||
40 | /** |
||
41 | * The table associated with the model. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $table = 'servers'; |
||
46 | |||
47 | /** |
||
48 | * The attributes excluded from the model's JSON form. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $hidden = ['daemonSecret', 'sftp_password']; |
||
53 | |||
54 | /** |
||
55 | * The attributes that should be mutated to dates. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $dates = ['deleted_at']; |
||
60 | |||
61 | /** |
||
62 | * Fields that are not mass assignable. |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at']; |
||
67 | |||
68 | /** |
||
69 | * Cast values to correct type. |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | protected $casts = [ |
||
74 | 'node_id' => 'integer', |
||
75 | 'suspended' => 'integer', |
||
76 | 'owner_id' => 'integer', |
||
77 | 'memory' => 'integer', |
||
78 | 'swap' => 'integer', |
||
79 | 'disk' => 'integer', |
||
80 | 'io' => 'integer', |
||
81 | 'cpu' => 'integer', |
||
82 | 'oom_disabled' => 'integer', |
||
83 | 'allocation_id' => 'integer', |
||
84 | 'service_id' => 'integer', |
||
85 | 'option_id' => 'integer', |
||
86 | 'pack_id' => 'integer', |
||
87 | 'installed' => 'integer', |
||
88 | ]; |
||
89 | |||
90 | /** |
||
91 | * Parameters for search querying. |
||
92 | * |
||
93 | * @var array |
||
94 | */ |
||
95 | protected $searchable = [ |
||
96 | 'columns' => [ |
||
97 | 'servers.name' => 10, |
||
98 | 'servers.username' => 10, |
||
99 | 'servers.uuidShort' => 9, |
||
100 | 'servers.uuid' => 8, |
||
101 | 'packs.name' => 7, |
||
102 | 'users.email' => 6, |
||
103 | 'users.username' => 6, |
||
104 | 'nodes.name' => 2, |
||
105 | ], |
||
106 | 'joins' => [ |
||
107 | 'packs' => ['packs.id', 'servers.pack_id'], |
||
108 | 'users' => ['users.id', 'servers.owner_id'], |
||
109 | 'nodes' => ['nodes.id', 'servers.node_id'], |
||
110 | ], |
||
111 | ]; |
||
112 | |||
113 | /** |
||
114 | * Returns a single server specified by UUID. |
||
115 | * DO NOT USE THIS TO MODIFY SERVER DETAILS OR SAVE THOSE DETAILS. |
||
116 | * YOU WILL OVERWRITE THE SECRET KEY AND BREAK THINGS. |
||
117 | * |
||
118 | * @param string $uuid |
||
119 | * @param array $with |
||
120 | * @param array $withCount |
||
121 | * @return \Pterodactyl\Models\Server |
||
122 | * @todo Remove $with and $withCount due to cache issues, they aren't used anyways. |
||
123 | */ |
||
124 | public static function byUuid($uuid, array $with = [], array $withCount = []) |
||
149 | |||
150 | /** |
||
151 | * Returns non-administrative headers for accessing a server on the daemon. |
||
152 | * |
||
153 | * @param Pterodactyl\Models\User|null $user |
||
154 | * @return array |
||
155 | */ |
||
156 | public function guzzleHeaders(User $user = null) |
||
169 | |||
170 | /** |
||
171 | * Return an instance of the Guzzle client for this specific server using defined access token. |
||
172 | * |
||
173 | * @param Pterodactyl\Models\User|null $user |
||
174 | * @return \GuzzleHttp\Client |
||
175 | */ |
||
176 | public function guzzleClient(User $user = null) |
||
180 | |||
181 | /** |
||
182 | * Returns javascript object to be embedded on server view pages with relevant information. |
||
183 | * |
||
184 | * @param array|null $additional |
||
185 | * @param array|null $overwrite |
||
186 | * @return \Laracasts\Utilities\JavaScript\JavaScriptFacade |
||
187 | */ |
||
188 | public function js($additional = null, $overwrite = null) |
||
214 | |||
215 | /** |
||
216 | * Return the columns available for this table. |
||
217 | * |
||
218 | * @return array |
||
219 | */ |
||
220 | public function getTableColumns() |
||
224 | |||
225 | /** |
||
226 | * Gets the user who owns the server. |
||
227 | * |
||
228 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
229 | */ |
||
230 | public function user() |
||
234 | |||
235 | /** |
||
236 | * Gets the subusers associated with a server. |
||
237 | * |
||
238 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
239 | */ |
||
240 | public function subusers() |
||
244 | |||
245 | /** |
||
246 | * Gets the default allocation for a server. |
||
247 | * |
||
248 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
249 | */ |
||
250 | public function allocation() |
||
254 | |||
255 | /** |
||
256 | * Gets all allocations associated with this server. |
||
257 | * |
||
258 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
259 | */ |
||
260 | public function allocations() |
||
264 | |||
265 | /** |
||
266 | * Gets information for the pack associated with this server. |
||
267 | * |
||
268 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
269 | */ |
||
270 | public function pack() |
||
274 | |||
275 | /** |
||
276 | * Gets information for the service associated with this server. |
||
277 | * |
||
278 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
279 | */ |
||
280 | public function service() |
||
284 | |||
285 | /** |
||
286 | * Gets information for the service option associated with this server. |
||
287 | * |
||
288 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
289 | */ |
||
290 | public function option() |
||
294 | |||
295 | /** |
||
296 | * Gets information for the service variables associated with this server. |
||
297 | * |
||
298 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
299 | */ |
||
300 | public function variables() |
||
304 | |||
305 | /** |
||
306 | * Gets information for the node associated with this server. |
||
307 | * |
||
308 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
309 | */ |
||
310 | public function node() |
||
314 | |||
315 | /** |
||
316 | * Gets information for the tasks associated with this server. |
||
317 | * |
||
318 | * @TODO adjust server column in tasks to be server_id |
||
319 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
320 | */ |
||
321 | public function tasks() |
||
325 | |||
326 | /** |
||
327 | * Gets all databases associated with a server. |
||
328 | * |
||
329 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
330 | */ |
||
331 | public function databases() |
||
335 | |||
336 | /** |
||
337 | * Gets all downloads associated with a server. |
||
338 | * |
||
339 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
340 | */ |
||
341 | public function downloads() |
||
345 | |||
346 | /** |
||
347 | * Gets the location of the server. |
||
348 | * |
||
349 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
350 | */ |
||
351 | public function location() |
||
355 | } |
||
356 |
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: