PageLink.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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\diy;
  12. use crmeb\basic\BaseModel;
  13. use crmeb\traits\ModelTrait;
  14. use think\Model;
  15. class PageLink extends BaseModel
  16. {
  17. use ModelTrait;
  18. /**
  19. * 数据表主键
  20. * @var string
  21. */
  22. protected $pk = 'id';
  23. /**
  24. * 模型名称
  25. * @var string
  26. */
  27. protected $name = 'page_link';
  28. /**
  29. * 分类搜索器
  30. * @param Model $query
  31. * @param $value
  32. */
  33. public function searchCateIdAttr($query, $value)
  34. {
  35. if ($value) {
  36. if (is_array($value)) {
  37. $query->whereIn('cate_id', $value);
  38. } else {
  39. $query->where('cate_id', $value);
  40. }
  41. }
  42. }
  43. /**
  44. * 是否使用搜索器
  45. * @param Model $query
  46. * @param $value
  47. */
  48. public function searchStatusAttr($query, $value)
  49. {
  50. if ($value != '') $query->where('status', $value);
  51. }
  52. /**
  53. * 模块检测
  54. * @param Model $query
  55. * @param $value
  56. */
  57. public function searchNoModelAttr($query, $value)
  58. {
  59. $query->when(!in_array('seckill', $value), function ($q1) {
  60. $q1->whereNotLike('name', '%秒杀%');
  61. })->when(!in_array('bargain', $value), function ($q2) {
  62. $q2->whereNotLike('name', '%砍价%');
  63. })->when(!in_array('combination', $value), function ($q3) {
  64. $q3->whereNotLike('name', '%拼团%');
  65. });
  66. }
  67. }