RandomRedPacketRecord.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace addons\RandomRedPacket\common\models;
  3. use common\models\user\User;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_random_red_packet_record".
  7. *
  8. * @property int $id
  9. * @property int $mall_id 商城id
  10. * @property int $uid 用户id
  11. * @property int $packet_id 红包id
  12. * @property string $reward_value 奖励值
  13. * @property int $created_at 创建时间
  14. * @property int $updated_at 修改时间
  15. */
  16. class RandomRedPacketRecord extends \common\models\base\BaseActiveRecord
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function tableName()
  22. {
  23. return 'qimall_addons_random_red_packet_record';
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function rules()
  29. {
  30. return [
  31. [['uid', 'packet_id', 'reward_value'], 'required'],
  32. [['uid', 'packet_id', 'created_at', 'updated_at'], 'integer'],
  33. ];
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function attributeLabels()
  39. {
  40. return [
  41. 'id' => 'ID',
  42. 'uid' => 'Uid',
  43. 'packet_id' => 'Packet ID',
  44. 'reward_value' => 'Reward Value',
  45. 'created_at' => 'Created At',
  46. 'updated_at' => 'Updated At',
  47. ];
  48. }
  49. /**
  50. * 关联随机红包信息
  51. * @Author: lun
  52. * @DateTime: 2023/2/18 0018 9:56
  53. * @Copyright: copyright (c) 2021 广东七件事集团
  54. * @return \yii\db\ActiveQuery
  55. */
  56. public function getRandomRedPacket()
  57. {
  58. return $this->hasOne(RandomRedPacket::class,['id' => 'packet_id']);
  59. }
  60. /**
  61. * 关联用户信息
  62. * @Author: lun
  63. * @DateTime: 2023/2/18 0018 9:56
  64. * @Copyright: copyright (c) 2021 广东七件事集团
  65. * @return \yii\db\ActiveQuery
  66. */
  67. public function getUser()
  68. {
  69. return $this->hasOne(User::class, ['id' => 'uid'])->select('nickname,avatar_url,id');
  70. }
  71. }