Project.php
1.6 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
<?php
namespace App\Models;
use App\Models\Devops\ServerConfig;
class Project extends Base
{
//设置关联表名
protected $table = 'gl_project';
const DATABASE_NAME_FIX = 'globalso_project_';
/**
* 星级客户
* @return string[]
* @author zbj
* @date 2023/4/25
*/
public static function levelMap()
{
return [
1 => '★★★Ads-Customer',
2 => '暂停优化',
3 => '告知书一',
4 => '告知书二',
5 => 'Q告知书二',
];
}
/**
* 项目部署服务器信息
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function serverConfig()
{
return self::hasOne(ServerConfig::class, 'id', 'serve_id');
}
/**
* 项目部署mysql数据库信息
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function mysqlConfig()
{
return self::hasOne(ServerConfig::class, 'id', 'mysql_id');
}
/**
* 项目使用Redis服务器信息, 如果没有即使用默认配置
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function redisConfig()
{
return self::hasOne(ServerConfig::class, 'id', 'redis_id');
}
/**
* 获取项目对应数据库名称
* 初始化数据库、数据表迭代等功能使用
* TODO 如果前缀变更,请使用该方法进行处理
* @return string
*/
public function databaseName()
{
return self::DATABASE_NAME_FIX . $this->id;
}
}