fieldExists('config_classify_id', $classify_id); } /** * @param $key * @param int|null $except * @return bool * @author zfy * @day 2020-03-27 */ public function keyExists($key, ?int $except = null): bool { return $this->fieldExists('config_key', $key, $except); } /** * @param array $where * @return BaseQuery * @author zfy * @day 2020-03-31 */ public function search(array $where) { $query = SystemConfig::getDB(); if ($where['keyword']) $query->whereLike('config_name|config_key', '%' . $where['keyword'] . '%'); if (isset($where['pid']) && $where['pid'] !== '') $query->where('config_classify_id', $where['pid']); if (isset($where['config_classify_id'])) $query->where('config_classify_id', $where['config_classify_id']); return $query; } /** * @param int $cid * @param int $user_type * @return Collection * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author zfy * @day 2020-04-23 */ public function cidByConfig(int $cid, int $user_type) { return SystemConfig::getDB()->where('config_classify_id', $cid)->where('user_type', $user_type)->where('status', 1)->select(); } /** * @param int $cid * @param $keys * @return array * @author zfy * @day 2020-04-22 */ public function intersectionKey(int $cid, $keys): array { return SystemConfig::where('config_classify_id', $cid)->whereIn('config_key', $keys)->where('status', 1)->column('config_type,config_name', 'config_key'); } }