// +---------------------------------------------------------------------- namespace app\common\dao\system\admin; use app\common\dao\BaseDao; use app\common\model\BaseModel; use app\common\model\system\admin\Partner; use app\common\model\user\UserPartner; use app\common\model\system\admin\Admin; use think\db\BaseQuery; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\Model; class PartnerDao extends BaseDao { /** * @return BaseModel * @author xaboy * @day 2020-03-30 */ protected function getModel(): string { return Partner::class; } /** * @param array $where * @return BaseQuery * @author xaboy * @day 2020-04-09 */ public function search(array $where = []) { $query = Partner::getDB(); if (isset($where['keyword']) && $where['keyword'] !== '') { $query = $query->whereLike('name', '%' . $where['keyword'] . '%'); } if (isset($where['status']) && $where['status'] !== '') { $query = $query->where('status', intval($where['status'])); } return $query; } public function existsUser(int $id) { return UserPartner::getInstance()->where('partner_id', $id) ->where('uid','<>','') ->field(['id']) ->find(); } public function getAll() { return Partner::getDB()->where('status', 1)->order('id desc')->field('')->select()->toArray(); } public function exists(int $id) { return $this->existsWhere(['id' => $id]); } }