1 | <?php |
||
32 | class Node extends Model |
||
33 | { |
||
34 | use Notifiable, SearchableTrait; |
||
35 | |||
36 | /** |
||
37 | * The table associated with the model. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $table = 'nodes'; |
||
42 | |||
43 | /** |
||
44 | * The attributes excluded from the model's JSON form. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $hidden = ['daemonSecret']; |
||
49 | |||
50 | /** |
||
51 | * Cast values to correct type. |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $casts = [ |
||
56 | 'public' => 'integer', |
||
57 | 'location_id' => 'integer', |
||
58 | 'memory' => 'integer', |
||
59 | 'disk' => 'integer', |
||
60 | 'daemonListen' => 'integer', |
||
61 | 'daemonSFTP' => 'integer', |
||
62 | 'behind_proxy' => 'boolean', |
||
63 | ]; |
||
64 | |||
65 | /** |
||
66 | * Fields that are mass assignable. |
||
67 | * |
||
68 | * @var array |
||
69 | */ |
||
70 | protected $fillable = [ |
||
71 | 'public', 'name', 'location_id', |
||
72 | 'fqdn', 'scheme', 'behind_proxy', |
||
73 | 'memory', 'memory_overallocate', 'disk', |
||
74 | 'disk_overallocate', 'upload_size', |
||
75 | 'daemonSecret', 'daemonBase', |
||
76 | 'daemonSFTP', 'daemonListen', |
||
77 | ]; |
||
78 | |||
79 | /** |
||
80 | * Fields that are searchable. |
||
81 | * |
||
82 | * @var array |
||
83 | */ |
||
84 | protected $searchable = [ |
||
85 | 'columns' => [ |
||
86 | 'nodes.name' => 10, |
||
87 | 'nodes.fqdn' => 8, |
||
88 | 'locations.short' => 4, |
||
89 | 'locations.long' => 4, |
||
90 | ], |
||
91 | 'joins' => [ |
||
92 | 'locations' => ['locations.id', 'nodes.location_id'], |
||
93 | ], |
||
94 | ]; |
||
95 | |||
96 | /** |
||
97 | * Return an instance of the Guzzle client for this specific node. |
||
98 | * |
||
99 | * @param array $headers |
||
100 | * @return \GuzzleHttp\Client |
||
101 | */ |
||
102 | public function guzzleClient($headers = []) |
||
111 | |||
112 | /** |
||
113 | * Returns the configuration in JSON format. |
||
114 | * |
||
115 | * @param bool $pretty |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getConfigurationAsJson($pretty = false) |
||
157 | |||
158 | /** |
||
159 | * Gets the location associated with a node. |
||
160 | * |
||
161 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
162 | */ |
||
163 | public function location() |
||
167 | |||
168 | /** |
||
169 | * Gets the servers associated with a node. |
||
170 | * |
||
171 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
172 | */ |
||
173 | public function servers() |
||
177 | |||
178 | /** |
||
179 | * Gets the allocations associated with a node. |
||
180 | * |
||
181 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
182 | */ |
||
183 | public function allocations() |
||
187 | } |
||
188 |