FeedbackDao.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020/5/28
  7. *
  8. *
  9. */
  10. namespace app\common\dao\user;
  11. use app\common\dao\BaseDao;
  12. use app\common\model\BaseModel;
  13. use app\common\model\user\Feedback;
  14. /**
  15. * Class FeedbackDao
  16. * @package app\common\dao\user
  17. * @author xaboy
  18. * @day 2020/5/28
  19. */
  20. class FeedbackDao extends BaseDao
  21. {
  22. /**
  23. * @return string
  24. * @author xaboy
  25. * @day 2020/5/28
  26. */
  27. protected function getModel(): string
  28. {
  29. return Feedback::class;
  30. }
  31. /**
  32. * @param array $where
  33. * @return \think\db\BaseQuery
  34. * @author xaboy
  35. * @day 2020/5/28
  36. */
  37. public function search(array $where)
  38. {
  39. return Feedback::getDB()->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
  40. $query->where('uid', $where['uid']);
  41. })->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
  42. $query->where('content','like', '%'.$where['keyword'].'%')->whereOr('reply','like', '%'.$where['keyword'].'%')->whereOr('remake','like', '%'.$where['keyword'].'%');
  43. })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
  44. $query->where('type',$where['type']);
  45. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  46. $query->where('status', $where['status']);
  47. })->when(isset($where['realname']) && $where['realname'] !== '', function ($query) use ($where) {
  48. $query->where('realname','like', '%'.$where['realname'].'%');
  49. })->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
  50. $query->where('is_del',$where['is_del']);
  51. });
  52. }
  53. /**
  54. * @param $id
  55. * @param $uid
  56. * @return bool
  57. * @author xaboy
  58. * @day 2020/5/28
  59. */
  60. public function uidExists($id, $uid): bool
  61. {
  62. return Feedback::getDB()->where($this->getPk(), $id)->where('uid', $uid)->where('is_del', 0)->count($this->getPk()) > 0;
  63. }
  64. }