SystemUserApply.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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\system;
  12. use app\model\user\User;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 用户申请
  18. * Class SystemUserApply
  19. * @package app\model\system\admin
  20. */
  21. class SystemUserApply 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 = 'system_user_apply';
  34. /**
  35. * 多图
  36. * @param $value
  37. * @return string
  38. */
  39. public function setImagesAttr($value)
  40. {
  41. if ($value) {
  42. return is_array($value) ? json_encode($value) : $value;
  43. }
  44. return '';
  45. }
  46. /**
  47. * 多图获取器
  48. * @param $value
  49. * @return array|mixed
  50. */
  51. public function getImagesAttr($value)
  52. {
  53. return is_string($value) ? json_decode($value, true) : [];
  54. }
  55. /**
  56. * 关联user
  57. * @return model\relation\HasOne
  58. */
  59. public function user()
  60. {
  61. return $this->hasOne(User::class, 'uid', 'uid');
  62. }
  63. /**
  64. * id搜索器
  65. * @param Model $query
  66. * @param $value
  67. */
  68. public function searchIdAttr($query, $value)
  69. {
  70. if (is_array($value)) {
  71. $query->whereIn('id', $value);
  72. } else {
  73. $query->where('id', $value);
  74. }
  75. }
  76. /**
  77. * 关键词搜索器
  78. * @param $query Model
  79. * @param $value
  80. */
  81. public function searchKeywordAttr($query, $value)
  82. {
  83. if ($value !== '') $query->where('id|uid|name|phone|system_name|fail_msg|mark', 'like', '%' . $value . '%');
  84. }
  85. /**
  86. * uid搜索器
  87. * @param Model $query
  88. * @param $value
  89. */
  90. public function searchUidAttr($query, $value)
  91. {
  92. if (is_array($value)) {
  93. if ($value) $query->whereIn('uid', $value);
  94. } else {
  95. if($value !== '') $query->where('uid', $value);
  96. }
  97. }
  98. /**
  99. * 商户搜索器
  100. * @param Model $query
  101. * @param $value
  102. */
  103. public function searchTypeAttr($query, $value)
  104. {
  105. if (is_array($value)) {
  106. if ($value) $query->whereIn('type', $value);
  107. } else {
  108. if ($value !== '') $query->where('type', $value);
  109. }
  110. }
  111. /**
  112. * 关联门店ID、供应商ID搜索器
  113. * @param Model $query
  114. * @param $value
  115. */
  116. public function searchRelationIdAttr($query, $value)
  117. {
  118. if (is_array($value)) {
  119. if ($value) $query->whereIn('relation_id', $value);
  120. } else {
  121. if ($value !== '') $query->where('relation_id', $value);
  122. }
  123. }
  124. /**
  125. * 权限规格状态搜索器
  126. * @param Model $query
  127. * @param $value
  128. */
  129. public function searchStatusAttr($query, $value)
  130. {
  131. if ($value != '') {
  132. $query->where('status', $value);
  133. }
  134. }
  135. /**
  136. * 是否删除搜索器
  137. * @param Model $query
  138. * @param $value
  139. * @param $data
  140. */
  141. public function searchIsDelAttr($query, $value)
  142. {
  143. if ($value !== '') $query->where('is_del', $value);
  144. }
  145. }