e608c5f7
Yarik
Comment added
|
1
2
3
4
5
|
<?php
namespace common\modules\comment\models;
use Yii;
|
c05bf005
Yarik
Comment added
|
6
7
|
use yii\behaviors\BlameableBehavior;
use yii\behaviors\TimestampBehavior;
|
e608c5f7
Yarik
Comment added
|
8
9
|
/**
|
c05bf005
Yarik
Comment added
|
10
|
* This is the model class for table "artbox_comment_rating".
|
e608c5f7
Yarik
Comment added
|
11
|
*
|
c05bf005
Yarik
Comment added
|
12
|
* @property integer $artbox_comment_rating_id
|
e608c5f7
Yarik
Comment added
|
13
14
15
16
17
18
19
20
21
|
* @property string $date_add
* @property string $date_update
* @property integer $user_id
* @property integer $value
* @property string $model
* @property integer $model_id
*
* @property \common\models\User $user
*/
|
c05bf005
Yarik
Comment added
|
22
|
class RatingModel extends \yii\db\ActiveRecord
|
e608c5f7
Yarik
Comment added
|
23
|
{
|
e608c5f7
Yarik
Comment added
|
24
25
26
27
28
|
/**
* @inheritdoc
*/
public static function tableName()
{
|
c05bf005
Yarik
Comment added
|
29
|
return 'artbox_comment_rating';
|
e608c5f7
Yarik
Comment added
|
30
31
32
33
34
35
36
37
|
}
/**
* @inheritdoc
*/
public function rules()
{
return [
|
c05bf005
Yarik
Comment added
|
38
39
|
[['value'], 'required'],
[['value'], 'number', 'min' => 0.5, 'max' => 5],
|
e608c5f7
Yarik
Comment added
|
40
41
|
];
}
|
c05bf005
Yarik
Comment added
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'date_add',
'updatedAtAttribute' => 'date_update',
],
[
'class' => BlameableBehavior::className(),
'createdByAttribute' => 'user_id',
'updatedByAttribute' => false,
],
];
}
|
e608c5f7
Yarik
Comment added
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'rating_id' => Yii::t('app', 'Rating ID'),
'date_add' => Yii::t('app', 'Date Add'),
'date_update' => Yii::t('app', 'Date Update'),
'user_id' => Yii::t('app', 'User ID'),
'entity' => Yii::t('app', 'Entity'),
'value' => Yii::t('app', 'Value'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(\common\models\User::className(), ['id' => 'user_id']);
}
|
c05bf005
Yarik
Comment added
|
81
82
83
84
85
86
|
public function getModel()
{
$model = $this->model;
return $this->hasOne($model, [$model::primaryKey() => 'model_id']);
}
|
e608c5f7
Yarik
Comment added
|
87
|
}
|