1 | <?php |
||
33 | class Server extends Model |
||
34 | { |
||
35 | use Notifiable, SoftDeletes; |
||
36 | |||
37 | /** |
||
38 | * The table associated with the model. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $table = 'servers'; |
||
43 | |||
44 | /** |
||
45 | * The attributes excluded from the model's JSON form. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $hidden = ['daemonSecret', 'sftp_password']; |
||
50 | |||
51 | /** |
||
52 | * The attributes that should be mutated to dates. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $dates = ['deleted_at']; |
||
57 | |||
58 | /** |
||
59 | * Fields that are not mass assignable. |
||
60 | * |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at']; |
||
64 | |||
65 | /** |
||
66 | * Cast values to correct type. |
||
67 | * |
||
68 | * @var array |
||
69 | */ |
||
70 | protected $casts = [ |
||
71 | 'node_id' => 'integer', |
||
72 | 'suspended' => 'integer', |
||
73 | 'owner_id' => 'integer', |
||
74 | 'memory' => 'integer', |
||
75 | 'swap' => 'integer', |
||
76 | 'disk' => 'integer', |
||
77 | 'io' => 'integer', |
||
78 | 'cpu' => 'integer', |
||
79 | 'oom_disabled' => 'integer', |
||
80 | 'allocation_id' => 'integer', |
||
81 | 'service_id' => 'integer', |
||
82 | 'option_id' => 'integer', |
||
83 | 'pack_id' => 'integer', |
||
84 | 'installed' => 'integer', |
||
85 | ]; |
||
86 | |||
87 | /** |
||
88 | * @var array |
||
89 | */ |
||
90 | protected static $serverUUIDInstance = []; |
||
91 | |||
92 | /** |
||
93 | * @var mixed |
||
94 | */ |
||
95 | protected static $user; |
||
96 | |||
97 | /** |
||
98 | * Constructor. |
||
99 | */ |
||
100 | public function __construct() |
||
105 | |||
106 | /** |
||
107 | * Returns a single server specified by UUID. |
||
108 | * DO NOT USE THIS TO MODIFY SERVER DETAILS OR SAVE THOSE DETAILS. |
||
109 | * YOU WILL OVERWRITE THE SECRET KEY AND BREAK THINGS. |
||
110 | * |
||
111 | * @param string $uuid The Short-UUID of the server to return an object about. |
||
112 | * @return \Illuminate\Database\Eloquent\Collection |
||
113 | */ |
||
114 | public static function byUuid($uuid) |
||
132 | |||
133 | /** |
||
134 | * Returns non-administrative headers for accessing a server on the daemon. |
||
135 | * |
||
136 | * @param string $uuid |
||
137 | * @return array |
||
138 | */ |
||
139 | public function guzzleHeaders() |
||
146 | |||
147 | /** |
||
148 | * Return an instance of the Guzzle client for this specific server using defined access token. |
||
149 | * |
||
150 | * @return \GuzzleHttp\Client |
||
151 | */ |
||
152 | public function guzzleClient() |
||
156 | |||
157 | /** |
||
158 | * Returns javascript object to be embedded on server view pages with relevant information. |
||
159 | * |
||
160 | * @return \Laracasts\Utilities\JavaScript\JavaScriptFacade |
||
161 | */ |
||
162 | public function js($additional = null, $overwrite = null) |
||
188 | |||
189 | /** |
||
190 | * Gets the user who owns the server. |
||
191 | * |
||
192 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
193 | */ |
||
194 | public function user() |
||
198 | |||
199 | /** |
||
200 | * Gets the subusers associated with a server. |
||
201 | * |
||
202 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
203 | */ |
||
204 | public function subusers() |
||
208 | |||
209 | /** |
||
210 | * Gets the default allocation for a server. |
||
211 | * |
||
212 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
213 | */ |
||
214 | public function allocation() |
||
218 | |||
219 | /** |
||
220 | * Gets all allocations associated with this server. |
||
221 | * |
||
222 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
223 | */ |
||
224 | public function allocations() |
||
228 | |||
229 | /** |
||
230 | * Gets information for the pack associated with this server. |
||
231 | * |
||
232 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
233 | */ |
||
234 | public function pack() |
||
238 | |||
239 | /** |
||
240 | * Gets information for the service associated with this server. |
||
241 | * |
||
242 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
243 | */ |
||
244 | public function service() |
||
248 | |||
249 | /** |
||
250 | * Gets information for the service option associated with this server. |
||
251 | * |
||
252 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
253 | */ |
||
254 | public function option() |
||
258 | |||
259 | /** |
||
260 | * Gets information for the service variables associated with this server. |
||
261 | * |
||
262 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
263 | */ |
||
264 | public function variables() |
||
268 | |||
269 | /** |
||
270 | * Gets information for the node associated with this server. |
||
271 | * |
||
272 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
273 | */ |
||
274 | public function node() |
||
278 | |||
279 | /** |
||
280 | * Gets information for the tasks associated with this server. |
||
281 | * |
||
282 | * @TODO adjust server column in tasks to be server_id |
||
283 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
284 | */ |
||
285 | public function tasks() |
||
289 | |||
290 | /** |
||
291 | * Gets all databases associated with a server. |
||
292 | * |
||
293 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
294 | */ |
||
295 | public function databases() |
||
299 | } |
||
300 |
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: