// +---------------------------------------------------------------------- namespace app\common\dao\system; use app\common\dao\BaseDao; use app\common\model\system\Relevance; use app\common\repositories\system\RelevanceRepository; class RelevanceDao extends BaseDao { protected function getModel(): string { return Relevance::class; } public function clear(int $id, $type, string $field = 'left_id') { if (is_string($type)) $type = [$type]; return $this->getModel()::getDb()->where($field, $id)->whereIn('type', $type)->delete(); } public function joinUser($where) { $query = Relevance::hasWhere('community',function($query) use($where){ $query->where('status',1)->where('is_show',1)->where('is_del',0); $query->when(isset($where['is_type']) && $where['is_type'] !== '',function($query) use($where){ $query->where('is_type',$where['is_type']); }); }); $query->where('left_id',$where['uid'])->where('type',RelevanceRepository::TYPE_COMMUNITY_START); return $query; } }