-
Notifications
You must be signed in to change notification settings - Fork 0
/
Comment.php
83 lines (76 loc) · 1.99 KB
/
Comment.php
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
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "{{%comment}}".
*
* @property integer $id
* @property integer $reply_to
* @property integer $post_id
* @property integer $user_id
* @property integer $date
* @property string $text_raw
* @property string $text
* @property string $ip
* @property integer $is_register
* @property integer $approve
*
* @property Post $post
* @property User $user
*/
class Comment extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%comment}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['reply_to', 'post_id', 'user_id', 'date', 'is_register', 'approve'], 'integer'],
[['post_id', 'user_id', 'date', 'text_raw', 'text', 'ip'], 'required'],
[['text_raw', 'text'], 'string'],
[['ip'], 'string', 'max' => 255],
[['post_id'], 'exist', 'skipOnError' => true, 'targetClass' => Post::className(), 'targetAttribute' => ['post_id' => 'id']],
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'reply_to' => 'Reply To',
'post_id' => 'Post ID',
'user_id' => 'User ID',
'date' => 'Date',
'text_raw' => 'Text Raw',
'text' => 'Text',
'ip' => 'Ip',
'is_register' => 'Is Register',
'approve' => 'Approve',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPost()
{
return $this->hasOne(Post::className(), ['id' => 'post_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}