GiftcodeModel.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * GiftcodeModel.php UTF-8
  4. * 礼包码页面
  5. *
  6. * @date : 2017/11/18 17:11
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\model\game;
  13. use huo\model\common\CommonModel;
  14. class GiftcodeModel extends CommonModel {
  15. protected $name = 'gift_code';
  16. //设置只读字段
  17. protected $readonly = ['gift_id', 'code', 'create_time'];
  18. // 开启自动写入时间戳字段
  19. protected $autoWriteTimestamp = true;
  20. //类型转换
  21. protected $type
  22. = [
  23. 'gift_id' => 'integer',
  24. 'mem_id' => 'integer'
  25. ];
  26. //模型关联方法
  27. protected $relationFilter = ['member', 'gift'];
  28. /**
  29. * 关联 member 表
  30. *
  31. * @return \think\model\relation\BelongsTo
  32. */
  33. public function member() {
  34. return $this->belongsTo('huo\model\member\MemberModel', 'mem_id');
  35. }
  36. /**
  37. * 关联 gift 表
  38. *
  39. */
  40. public function gift() {
  41. return $this->belongsTo('huo\model\game\GiftModel', 'gift_id', 'id',[], 'left')->setEagerlyType(0);
  42. }
  43. }