ServerInformation.php
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
namespace App\Models\Devops;
use App\Models\Base;
/**
* App\Models\Devops\ServerInformation
*
* @property int $id
* @property string $type 服务器类型
* @property string|null $ip 服务器ip
* @property string|null $title 服务器标题
* @property string $belong_to 服务器归属 1 - 公司 2 - 客户
* @property string|null $sshpass SSH 密码
* @property int|null $ports SSH 端口
* @property string|null $other 其他信息 json格式
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property int|null $deleted 软删除 0 - 正常 1 - 软删除
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation query()
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereBelongTo($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereDeleted($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereIp($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereOther($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation wherePorts($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereSshpass($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|ServerInformation whereUpdatedAt($value)
* @mixin \Eloquent
*/
class ServerInformation extends Base
{
protected $table = 'gl_server_information';
// 软删除 0:正常 1:删除
const DELETED_NORMAL = 0;
const DELETED_DELETE = 1;
/**
* @param $num
*
* @return string
*/
public function Service($num)
{
return $this->ServiceArray()[$num];
}
/**
* @return array
*/
public function ServiceArray()
{
return [
1 => '阿里云',
2 => '腾讯云',
3 => 'linode',
4 => '尊云',
5 => '互联',
6 => '其他',
7 => 'Ramnode',
8 => 'CN2-SSD美国',
9 => '国内测试服务器',
];
}
public function ServiceStr($num)
{
return array_flip($this->ServiceArray())[$num];
}
/**
* 字段信息
* @return array
*/
public function FieldsArray()
{
return [
'type' => '服务器类型',
'ip' => '服务器IP',
'title' => '服务器标题',
'belong_to' => '服务器归属',
'sshpass' => 'SSH 密码',
'ports' => 'SSH 端口',
'other' => '其他信息 json格式',
];
}
/**
* 服务器归属信息
* @return array
*/
public function BelongToArray()
{
return [
1 => '公司',
2 => '客户',
];
}
public function BelongToStr($num)
{
return array_flip($this->BelongToArray())[$num];
}
public function BelongTo($num)
{
return $this->BelongToArray()[$num];
}
/**
* 返回服务器类型
* @param $value
*
* @return string
*/
public function getTypeAttribute($value)
{
return $this->Service($value);
}
/**
* 返回服务器归属
* @param $value
*
* @return string
*/
public function getBelongToAttribute($value)
{
return $this->BelongTo($value);
}
}