Code Duplication    Length = 45-45 lines in 2 locations

common/models/MediaComment.php 1 location

@@ 23-67 (lines=45) @@
20
 * @author Agiel K. Saputra <[email protected]>
21
 * @since 0.1.0
22
 */
23
class MediaComment extends BaseComment
24
{
25
    /**
26
     * @var string
27
     */
28
    public $media_title;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public static function tableName()
34
    {
35
        return '{{%media_comment}}';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function rules()
42
    {
43
        return ArrayHelper::merge(parent::rules(), [
44
            ['media_id', 'required'],
45
            ['media_id', 'integer'],
46
        ]);
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function attributeLabels()
53
    {
54
        return ArrayHelper::merge(parent::attributeLabels(), [
55
            'media_id' => Yii::t('writesdown', 'Comment to'),
56
            'media_title' => Yii::t('writesdown', 'Media Title'),
57
        ]);
58
    }
59
60
    /**
61
     * @return \yii\db\ActiveQuery
62
     */
63
    public function getCommentMedia()
64
    {
65
        return $this->hasOne(Media::className(), ['id' => 'media_id']);
66
    }
67
}
68

common/models/PostComment.php 1 location

@@ 23-67 (lines=45) @@
20
 * @author Agiel K. Saputra <[email protected]>
21
 * @since 0.1.0
22
 */
23
class PostComment extends BaseComment
24
{
25
    /**
26
     * @var string
27
     */
28
    public $post_title;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public static function tableName()
34
    {
35
        return '{{%post_comment}}';
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function rules()
42
    {
43
        return ArrayHelper::merge(parent::rules(), [
44
            ['post_id', 'required'],
45
            ['post_id', 'integer'],
46
        ]);
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function attributeLabels()
53
    {
54
        return ArrayHelper::merge(parent::attributeLabels(), [
55
            'post_id' => Yii::t('writesdown', 'Comment to'),
56
            'post_title' => Yii::t('writesdown', 'Post Title'),
57
        ]);
58
    }
59
60
    /**
61
     * @return \yii\db\ActiveQuery
62
     */
63
    public function getCommentPost()
64
    {
65
        return $this->hasOne(Post::className(), ['id' => 'post_id']);
66
    }
67
}
68