| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- /**
- * @package merchant
- *
- * @author xaboy
- * @day 2020/5/28
- *
- *
- */
- namespace app\common\dao\user;
- use app\common\dao\BaseDao;
- use app\common\model\BaseModel;
- use app\common\model\user\Feedback;
- /**
- * Class FeedbackDao
- * @package app\common\dao\user
- * @author xaboy
- * @day 2020/5/28
- */
- class FeedbackDao extends BaseDao
- {
- /**
- * @return string
- * @author xaboy
- * @day 2020/5/28
- */
- protected function getModel(): string
- {
- return Feedback::class;
- }
- /**
- * @param array $where
- * @return \think\db\BaseQuery
- * @author xaboy
- * @day 2020/5/28
- */
- public function search(array $where)
- {
- return Feedback::getDB()->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
- $query->where('uid', $where['uid']);
- })->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
- $query->where('content', 'like', '%' . $where['keyword'] . '%')->whereOr('reply', 'like', '%' . $where['keyword'] . '%')->whereOr('remake', 'like', '%' . $where['keyword'] . '%');
- })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
- $query->where('type', $where['type']);
- })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
- $query->where('status', $where['status']);
- })->when(isset($where['realname']) && $where['realname'] !== '', function ($query) use ($where) {
- $query->where('realname', 'like', '%' . $where['realname'] . '%');
- })->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
- $query->where('is_del', $where['is_del']);
- })->when(isset($where['feedback_id']) && $where['feedback_id'] !== '', function ($query) use ($where) {
- $query->where('feedback_id', 'in', $where['feedback_id']);
- });
- }
- /**
- * @param $id
- * @param $uid
- * @return bool
- * @author xaboy
- * @day 2020/5/28
- */
- public function uidExists($id, $uid): bool
- {
- return Feedback::getDB()->where($this->getPk(), $id)->where('uid', $uid)->where('is_del', 0)->count($this->getPk()) > 0;
- }
- }
|