1 | <?php |
||
34 | class Server extends Model |
||
35 | { |
||
36 | use Notifiable, SoftDeletes; |
||
37 | |||
38 | /** |
||
39 | * The table associated with the model. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $table = 'servers'; |
||
44 | |||
45 | /** |
||
46 | * The attributes excluded from the model's JSON form. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $hidden = ['daemonSecret', 'sftp_password']; |
||
51 | |||
52 | /** |
||
53 | * The attributes that should be mutated to dates. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $dates = ['deleted_at']; |
||
58 | |||
59 | /** |
||
60 | * Fields that are not mass assignable. |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at']; |
||
65 | |||
66 | /** |
||
67 | * Cast values to correct type. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $casts = [ |
||
72 | 'node_id' => 'integer', |
||
73 | 'suspended' => 'integer', |
||
74 | 'owner_id' => 'integer', |
||
75 | 'memory' => 'integer', |
||
76 | 'swap' => 'integer', |
||
77 | 'disk' => 'integer', |
||
78 | 'io' => 'integer', |
||
79 | 'cpu' => 'integer', |
||
80 | 'oom_disabled' => 'integer', |
||
81 | 'allocation_id' => 'integer', |
||
82 | 'service_id' => 'integer', |
||
83 | 'option_id' => 'integer', |
||
84 | 'pack_id' => 'integer', |
||
85 | 'installed' => 'integer', |
||
86 | ]; |
||
87 | |||
88 | /** |
||
89 | * Returns a single server specified by UUID. |
||
90 | * DO NOT USE THIS TO MODIFY SERVER DETAILS OR SAVE THOSE DETAILS. |
||
91 | * YOU WILL OVERWRITE THE SECRET KEY AND BREAK THINGS. |
||
92 | * |
||
93 | * @param string $uuid The Short-UUID of the server to return an object about. |
||
94 | * @return \Illuminate\Database\Eloquent\Collection |
||
95 | */ |
||
96 | public static function byUuid($uuid) |
||
117 | |||
118 | /** |
||
119 | * Returns non-administrative headers for accessing a server on the daemon. |
||
120 | * |
||
121 | * @param string $uuid |
||
122 | * @return array |
||
123 | */ |
||
124 | public function guzzleHeaders() |
||
131 | |||
132 | /** |
||
133 | * Return an instance of the Guzzle client for this specific server using defined access token. |
||
134 | * |
||
135 | * @return \GuzzleHttp\Client |
||
136 | */ |
||
137 | public function guzzleClient() |
||
141 | |||
142 | /** |
||
143 | * Returns javascript object to be embedded on server view pages with relevant information. |
||
144 | * |
||
145 | * @return \Laracasts\Utilities\JavaScript\JavaScriptFacade |
||
146 | */ |
||
147 | public function js($additional = null, $overwrite = null) |
||
173 | |||
174 | /** |
||
175 | * Gets the user who owns the server. |
||
176 | * |
||
177 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
178 | */ |
||
179 | public function user() |
||
183 | |||
184 | /** |
||
185 | * Gets the subusers associated with a server. |
||
186 | * |
||
187 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
188 | */ |
||
189 | public function subusers() |
||
193 | |||
194 | /** |
||
195 | * Gets the default allocation for a server. |
||
196 | * |
||
197 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
198 | */ |
||
199 | public function allocation() |
||
203 | |||
204 | /** |
||
205 | * Gets all allocations associated with this server. |
||
206 | * |
||
207 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
208 | */ |
||
209 | public function allocations() |
||
213 | |||
214 | /** |
||
215 | * Gets information for the pack associated with this server. |
||
216 | * |
||
217 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
218 | */ |
||
219 | public function pack() |
||
223 | |||
224 | /** |
||
225 | * Gets information for the service associated with this server. |
||
226 | * |
||
227 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
228 | */ |
||
229 | public function service() |
||
233 | |||
234 | /** |
||
235 | * Gets information for the service option associated with this server. |
||
236 | * |
||
237 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
238 | */ |
||
239 | public function option() |
||
243 | |||
244 | /** |
||
245 | * Gets information for the service variables associated with this server. |
||
246 | * |
||
247 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
248 | */ |
||
249 | public function variables() |
||
253 | |||
254 | /** |
||
255 | * Gets information for the node associated with this server. |
||
256 | * |
||
257 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
258 | */ |
||
259 | public function node() |
||
263 | |||
264 | /** |
||
265 | * Gets information for the tasks associated with this server. |
||
266 | * |
||
267 | * @TODO adjust server column in tasks to be server_id |
||
268 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
269 | */ |
||
270 | public function tasks() |
||
274 | |||
275 | /** |
||
276 | * Gets all databases associated with a server. |
||
277 | * |
||
278 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
279 | */ |
||
280 | public function databases() |
||
284 | } |
||
285 |
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: