LiveComment.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\behaviors\TimestampBehavior;
  10. use yii\db\ActiveRecord;
  11. /**
  12. * This is the model class for table "{{%live_comment}}".
  13. *
  14. * @property $id int(11) NOT NULL AUTO_INCREMENT,
  15. * @property $store_id int(11) DEFAULT NULL,
  16. * @property $content text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '评论内容',
  17. * @property $room_id int(11) NOT NULL COMMENT '直播间id',
  18. * @property $user_id int(11) NOT NULL COMMENT '评论人id',
  19. * @property $type tinyint(1) NOT NULL DEFAULT '0' COMMENT '评论类型:0普通用户评论,2,管理员评论, 3 提示',
  20. * @property $created_at int(11) NULL DEFAULT 0 ,
  21. */
  22. class LiveComment extends \yii\db\ActiveRecord
  23. {
  24. const TYPE_DEFAULT = 0;
  25. const TYPE_ADMIN = 2;
  26. const TYPE_INFO = 3;
  27. public static $type_list = [
  28. self::TYPE_DEFAULT => '用户评论',
  29. self::TYPE_ADMIN => '管理员评论',
  30. self::TYPE_INFO => '提示',
  31. ];
  32. /**
  33. * @inheritdoc
  34. */
  35. public static function tableName()
  36. {
  37. return '{{%live_comment}}';
  38. }
  39. public function behaviors()
  40. {
  41. return [
  42. [
  43. // 自动更新创建和更新时间
  44. 'class' => TimestampBehavior::class,
  45. 'updatedAtAttribute' => false,
  46. ]
  47. ];
  48. }
  49. public static function type_name($type) {
  50. return self::$type_list[$type] ?? '';
  51. }
  52. }