Diy.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\system\diy;
  12. use app\common\model\BaseModel;
  13. class Diy extends BaseModel
  14. {
  15. public static function tablePk(): string
  16. {
  17. return 'id';
  18. }
  19. public static function tableName(): string
  20. {
  21. return 'diy';
  22. }
  23. public function searchTypeAttr($query,$value)
  24. {
  25. if (is_array($value)) {
  26. $query->whereIn('type',$value);
  27. } else {
  28. $query->where('type',$value);
  29. }
  30. }
  31. public function searchMerIdAttr($query, $value)
  32. {
  33. if ($value) {
  34. $query->where(function ($query) use ($value){
  35. $query->where('mer_id', $value)->whereOr('is_default',2);
  36. });
  37. } else {
  38. $query->where('mer_id', $value)->where('is_default','<',2);
  39. }
  40. }
  41. public function searchIsDefaultAttr($query, $value)
  42. {
  43. $query->where('is_default', $value);
  44. }
  45. }