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 | 'skip_scripts' => 'boolean', |
||
76 | 'suspended' => 'integer', |
||
77 | 'owner_id' => 'integer', |
||
78 | 'memory' => 'integer', |
||
79 | 'swap' => 'integer', |
||
80 | 'disk' => 'integer', |
||
81 | 'io' => 'integer', |
||
82 | 'cpu' => 'integer', |
||
83 | 'oom_disabled' => 'integer', |
||
84 | 'allocation_id' => 'integer', |
||
85 | 'service_id' => 'integer', |
||
86 | 'option_id' => 'integer', |
||
87 | 'pack_id' => 'integer', |
||
88 | 'installed' => 'integer', |
||
89 | ]; |
||
90 | |||
91 | /** |
||
92 | * Parameters for search querying. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $searchable = [ |
||
97 | 'columns' => [ |
||
98 | 'servers.name' => 10, |
||
99 | 'servers.username' => 10, |
||
100 | 'servers.uuidShort' => 9, |
||
101 | 'servers.uuid' => 8, |
||
102 | 'packs.name' => 7, |
||
103 | 'users.email' => 6, |
||
104 | 'users.username' => 6, |
||
105 | 'nodes.name' => 2, |
||
106 | ], |
||
107 | 'joins' => [ |
||
108 | 'packs' => ['packs.id', 'servers.pack_id'], |
||
109 | 'users' => ['users.id', 'servers.owner_id'], |
||
110 | 'nodes' => ['nodes.id', 'servers.node_id'], |
||
111 | ], |
||
112 | ]; |
||
113 | |||
114 | /** |
||
115 | * Returns a single server specified by UUID. |
||
116 | * DO NOT USE THIS TO MODIFY SERVER DETAILS OR SAVE THOSE DETAILS. |
||
117 | * YOU WILL OVERWRITE THE SECRET KEY AND BREAK THINGS. |
||
118 | * |
||
119 | * @param string $uuid |
||
120 | * @param array $with |
||
121 | * @param array $withCount |
||
122 | * @return \Pterodactyl\Models\Server |
||
123 | * @todo Remove $with and $withCount due to cache issues, they aren't used anyways. |
||
124 | */ |
||
125 | public static function byUuid($uuid, array $with = [], array $withCount = []) |
||
150 | |||
151 | /** |
||
152 | * Returns non-administrative headers for accessing a server on the daemon. |
||
153 | * |
||
154 | * @param Pterodactyl\Models\User|null $user |
||
155 | * @return array |
||
156 | */ |
||
157 | public function guzzleHeaders(User $user = null) |
||
170 | |||
171 | /** |
||
172 | * Return an instance of the Guzzle client for this specific server using defined access token. |
||
173 | * |
||
174 | * @param Pterodactyl\Models\User|null $user |
||
175 | * @return \GuzzleHttp\Client |
||
176 | */ |
||
177 | public function guzzleClient(User $user = null) |
||
181 | |||
182 | /** |
||
183 | * Returns javascript object to be embedded on server view pages with relevant information. |
||
184 | * |
||
185 | * @param array|null $additional |
||
186 | * @param array|null $overwrite |
||
187 | * @return \Laracasts\Utilities\JavaScript\JavaScriptFacade |
||
188 | */ |
||
189 | public function js($additional = null, $overwrite = null) |
||
215 | |||
216 | /** |
||
217 | * Return the columns available for this table. |
||
218 | * |
||
219 | * @return array |
||
220 | */ |
||
221 | public function getTableColumns() |
||
225 | |||
226 | /** |
||
227 | * Gets the user who owns the server. |
||
228 | * |
||
229 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
230 | */ |
||
231 | public function user() |
||
235 | |||
236 | /** |
||
237 | * Gets the subusers associated with a server. |
||
238 | * |
||
239 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
240 | */ |
||
241 | public function subusers() |
||
245 | |||
246 | /** |
||
247 | * Gets the default allocation for a server. |
||
248 | * |
||
249 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
250 | */ |
||
251 | public function allocation() |
||
255 | |||
256 | /** |
||
257 | * Gets all allocations associated with this server. |
||
258 | * |
||
259 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
260 | */ |
||
261 | public function allocations() |
||
265 | |||
266 | /** |
||
267 | * Gets information for the pack associated with this server. |
||
268 | * |
||
269 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
270 | */ |
||
271 | public function pack() |
||
275 | |||
276 | /** |
||
277 | * Gets information for the service associated with this server. |
||
278 | * |
||
279 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
280 | */ |
||
281 | public function service() |
||
285 | |||
286 | /** |
||
287 | * Gets information for the service option associated with this server. |
||
288 | * |
||
289 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
290 | */ |
||
291 | public function option() |
||
295 | |||
296 | /** |
||
297 | * Gets information for the service variables associated with this server. |
||
298 | * |
||
299 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
300 | */ |
||
301 | public function variables() |
||
305 | |||
306 | /** |
||
307 | * Gets information for the node associated with this server. |
||
308 | * |
||
309 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
310 | */ |
||
311 | public function node() |
||
315 | |||
316 | /** |
||
317 | * Gets information for the tasks associated with this server. |
||
318 | * |
||
319 | * @TODO adjust server column in tasks to be server_id |
||
320 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
321 | */ |
||
322 | public function tasks() |
||
326 | |||
327 | /** |
||
328 | * Gets all databases associated with a server. |
||
329 | * |
||
330 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
331 | */ |
||
332 | public function databases() |
||
336 | |||
337 | /** |
||
338 | * Gets the location of the server. |
||
339 | * |
||
340 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
341 | */ |
||
342 | public function location() |
||
346 | } |
||
347 |
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: