| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2025 赤店商城 All rights reserved.
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- class QuanziComment extends \yii\db\ActiveRecord
- {
- const TYPE_COMMENT = 0; //评论帖子
- const TYPE_REPLY = 1; //回复评论
- const TYPE_GOOD = 2; //点赞
- const TYPE_SHARE = 3; //分享
- const TYPE_WEIGUI = 4; //举报文章
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%quanzi_comment}}';
- }
- public function behaviors()
- {
- return [
- [
- // 自动更新创建和更新时间
- 'class' => TimestampBehavior::class,
- 'updatedAtAttribute' => null,
- ]
- ];
- }
-
- public static function type($k = null, $comment = null) {
- $arr = [
- self::TYPE_COMMENT => '评论',
- self::TYPE_REPLY => '回复',
- self::TYPE_GOOD => '点赞',
- self::TYPE_SHARE => '分享',
- self::TYPE_WEIGUI => '举报',
- ];
- if($k === null){
- return $arr;
- }
- $kname = isset($arr[$k]) ? $arr[$k] : '--';
- if($comment){
- $for = $comment['at_comment_id'] ? '回复' : ($comment['comment_id'] ? '评论' : '文章');
- if(in_array($k, [self::TYPE_WEIGUI, self::TYPE_GOOD])){
- $kname .= $for;
- }
- }
- return $kname;
- }
-
- public static function typeWeigui($k = null) {
- $arr = [
- 1 => '低俗色情',
- 2 => '涉嫌违法',
- 3 => '侵权抄袭',
- 4 => '人身攻击',
- 5 => '内容不实',
- ];
- if($k === null){
- return $arr;
- }
- return isset($arr[$k]) ? $arr[$k] : '--';
- }
-
- public function afterSave($insert, $changedAttributes) {
- parent::afterSave($insert, $changedAttributes);
-
- \app\modules\admin\models\quanzi\QuanziForm::afterCommentSave($this, $insert, $changedAttributes);
- }
- }
|