Room.php
3.59 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
141
142
143
144
145
146
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "{{%room}}".
*
* @property string $id
* @property string $room_id
* @property string $title
* @property string $master_id
* @property string $pic
* @property integer $starting_time
* @property string $starting_pic
* @property string $secret
* @property string $best
* @property string $vest
* @property integer $status
* @property integer $create_time
* @property integer $update_time
*/
class Room extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%room}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['room_id', 'master_id', 'starting_time', 'best', 'vest', 'living', 'status', 'unstart_sort', 'living_sort', 'create_time', 'update_time'], 'integer'],
[['title', 'watermark'], 'string', 'max' => 100],
[['app', 'secret'], 'string', 'max' => 50],
[['pic', 'background_pic'], 'string', 'max' => 255],
[['room_id'], 'unique'],
[['secret'], 'unique'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'room_id' => 'Room ID',
'title' => 'Title',
'watermark' => 'Watermark',
'master_id' => 'Master ID',
'app' => 'App',
'secret' => 'Secret',
'pic' => 'Pic',
'background_pic' => 'Background Pic',
'starting_time' => 'Starting Time',
'best' => 'Best',
'vest' => 'Vest',
'living' => 'Living',
'status' => 'Status',
'create_time' => 'Create Time',
'update_time' => 'Update Time',
];
}
public function behaviors() {
return [
[
'class' => \yii\behaviors\TimestampBehavior::className(),
'createdAtAttribute' => 'create_time',
'updatedAtAttribute' => 'update_time',
]
];
}
/**
* 关联表-主播
* @return type
*/
public function getMaster()
{
return $this->hasOne(Master::className(), ['master_id'=>'master_id']);
}
/**
* 关联表-计数
* @return type
*/
public function getRoomNums()
{
return $this->hasOne(RoomNums::className(), ['room_id'=>'room_id']);
}
/**
* 关联表-视频
* @return type
*/
public function getVideo()
{
return $this->hasMany(Video::className(), ['room_id'=>'room_id']);
}
/**
* 关联表-正在录制的视频
* @return type
*/
public function getVideoRecording()
{
return $this->hasOne(Video::className(), ['room_id'=>'room_id'])->where(['and',['>','live_start_time',0],['live_end_time'=>0]])->orderBy(['live_start_time'=>SORT_DESC]);
}
/**
* 关联表-最后录制的视频
* @return type
*/
public function getVideoLast()
{
return $this->hasOne(Video::className(), ['room_id'=>'room_id'])->where(['>','live_end_time',0])->orderBy(['create_time'=>SORT_DESC]);
}
/**
* 关联表-腾讯云频道
* @return type
*/
public function getRoomQchannel()
{
return $this->hasOne(RoomQchannel::className(), ['room_id'=>'room_id']);
}
/**
* 关联表-房间附属信息
* @return type
*/
public function getRoomInfo()
{
return $this->hasOne(RoomInfo::className(), ['room_id'=>'room_id']);
}
}