StoreServiceReplyDao.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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\dao\store\service;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\store\service\StoreServiceReply;
  14. /**
  15. * Class StoreServiceDao
  16. * @package app\common\dao\store\service
  17. * @author xaboy
  18. * @day 2020/5/29
  19. */
  20. class StoreServiceReplyDao extends BaseDao
  21. {
  22. /**
  23. * @return string
  24. * @author xaboy
  25. * @day 2020/5/29
  26. */
  27. protected function getModel(): string
  28. {
  29. return StoreServiceReply::class;
  30. }
  31. public function search(array $where)
  32. {
  33. return StoreServiceReply::getDB()->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
  34. $query->where('mer_id', $where['mer_id']);
  35. })->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
  36. $query->whereLike('keyword', "%{$where['keyword']}%");
  37. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  38. $query->where('status', $where['status']);
  39. });
  40. }
  41. public function keywordByValidData($key, $merId)
  42. {
  43. return StoreServiceReply::getDB()->where(function ($query) use ($key) {
  44. $query->where('keyword', 'like',"%{$key}%")->whereFieldRaw('CONCAT(\',\',`keyword`,\',\')', 'LIKE', '%,' . $key . ',%', 'OR');
  45. })->where('status', 1)->where('mer_id', $merId)->find();
  46. }
  47. }