Video.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. namespace app\model\activity\video;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. /**
  16. * 视频Model
  17. * Class StoreSeckill
  18. * @package app\model\activity\seckill
  19. */
  20. class Video extends BaseModel
  21. {
  22. use ModelTrait;
  23. /**
  24. * 数据表主键
  25. * @var string
  26. */
  27. protected $pk = 'id';
  28. /**
  29. * 模型名称
  30. * @var string
  31. */
  32. protected $name = 'video';
  33. /**
  34. * 关联商品ID
  35. * @param $value
  36. * @return false|string
  37. */
  38. protected function setProductIdAttr($value)
  39. {
  40. if ($value) {
  41. return is_array($value) ? implode(',', $value) : $value;
  42. }
  43. return '';
  44. }
  45. /**
  46. * 关联商品ID
  47. * @param $value
  48. * @return mixed
  49. */
  50. protected function getProductIdAttr($value)
  51. {
  52. if ($value) {
  53. return is_string($value) ? explode(',', $value) : $value;
  54. }
  55. return [];
  56. }
  57. /**
  58. * 商户搜索器
  59. * @param Model $query
  60. * @param $value
  61. */
  62. public function searchTypeAttr($query, $value)
  63. {
  64. if (is_array($value)) {
  65. if ($value) $query->whereIn('type', $value);
  66. } else {
  67. if ($value !== '') $query->where('type', $value);
  68. }
  69. }
  70. /**
  71. * 关联门店ID、供应商ID搜索器
  72. * @param Model $query
  73. * @param $value
  74. */
  75. public function searchRelationIdAttr($query, $value)
  76. {
  77. if (is_array($value)) {
  78. if ($value) $query->whereIn('relation_id', $value);
  79. } else {
  80. if ($value !== '') $query->where('relation_id', $value);
  81. }
  82. }
  83. /**
  84. * 状态搜索器
  85. * @param Model $query
  86. * @param $value
  87. * @param $data
  88. */
  89. public function searchIsShowAttr($query, $value, $data)
  90. {
  91. $query->where('is_show', $value ?? 1);
  92. }
  93. /**
  94. * 推荐搜索器
  95. * @param Model $query
  96. * @param $value
  97. * @param $data
  98. */
  99. public function searchIsRecommendAttr($query, $value, $data)
  100. {
  101. $query->where('is_recommend', $value ?? 1);
  102. }
  103. /**
  104. * 是否审核搜索器
  105. * @param $query
  106. * @param $value
  107. */
  108. public function searchIsVerifyAttr($query, $value)
  109. {
  110. if ($value !== '') $query->where('is_verify', $value ?? 1);
  111. }
  112. /**
  113. * 是否删除搜索器
  114. * @param Model $query
  115. * @param $value
  116. * @param $data
  117. */
  118. public function searchIsDelAttr($query, $value, $data)
  119. {
  120. $query->where('is_del', $value ?? 0);
  121. }
  122. }