LuckPrize.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\model\activity\lottery;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. *
  18. * Class LuckPrizeDao
  19. * @package app\model\activity\lottery
  20. */
  21. class LuckPrize extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 数据表主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'luck_prize';
  34. /**
  35. * 关联抽奖
  36. * @return \think\model\relation\HasOne
  37. */
  38. public function lottery()
  39. {
  40. return $this->hasOne(LuckLottery::class, 'id', 'lottery_id');
  41. }
  42. /**
  43. * 抽奖id搜索器
  44. * @param $query Model
  45. * @param $value
  46. */
  47. public function searchLotteryIdAttr($query, $value)
  48. {
  49. if ($value) $query->where('lottery_id', $value);
  50. }
  51. /**
  52. * 奖品类型搜索器
  53. * @param $query Model
  54. * @param $value
  55. */
  56. public function searchTypeAttr($query, $value)
  57. {
  58. if ($value) $query->where('type', $value);
  59. }
  60. /**
  61. * 状态搜索器
  62. * @param $query Model
  63. * @param $value
  64. */
  65. public function searchStatusAttr($query, $value)
  66. {
  67. if ($value !== '') $query->where('status', $value);
  68. }
  69. /**
  70. * 是否删除搜索器
  71. * @param $query Model
  72. * @param $value
  73. */
  74. public function searchIsDelAttr($query, $value)
  75. {
  76. if ($value !== '') $query->where('is_del', $value);
  77. }
  78. }