You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB

  1. <?php
  2. namespace backend\modules\shop\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "ats_comment".
  7. *
  8. * @property int $id
  9. * @property int $user_id 用户id
  10. * @property int $order_goods_id 订单详情商品id
  11. * @property int $star 星级
  12. * @property string $content 评论内容
  13. * @property int $status 状态:1为显示,0为不显示
  14. * @property int $updated_at 更新时间
  15. * @property int $created_at 创建时间
  16. * @property string $nickname 昵称
  17. * @property int $avatar 头像
  18. */
  19. class Comment extends \yii\db\ActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return 'ats_comment';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['user_id', 'order_goods_id', 'star', 'status', 'avatar'], 'integer'],
  35. [['content'], 'string'],
  36. [['nickname'], 'string', 'max' => 120],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'id',
  46. 'user_id' => '用户id',
  47. 'order_goods_id' => '订单详情商品id',
  48. 'star' => '星级',
  49. 'content' => '评论内容',
  50. 'status' => '状态:1为显示,0为不显示',
  51. 'updated_at' => '更新时间',
  52. 'created_at' => '创建时间',
  53. 'nickname' => '昵称',
  54. 'avatar' => '头像',
  55. ];
  56. }
  57. /**
  58. * @author linyao
  59. * @email 602604991@qq.com
  60. * @created Nov 8, 2019
  61. *
  62. * 行为存储创建时间和更新时间
  63. */
  64. public function behaviors()
  65. {
  66. return [
  67. [
  68. 'class' => TimestampBehavior::className(),
  69. 'createdAtAttribute' => 'created_at',
  70. 'updatedAtAttribute' => 'updated_at',
  71. 'value' => function() {
  72. return time();
  73. },
  74. ],
  75. ];
  76. }
  77. }