123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- namespace app\dao\system\config;
- use app\dao\BaseDao;
- use app\model\system\config\SystemConfig;
- class SystemConfigDao extends BaseDao
- {
-
- protected function setModel(): string
- {
- return SystemConfig::class;
- }
-
- public function getConfigValue(string $configNmae, int $storeId = 0)
- {
- return $this->withSearchSelect(['menu_name', 'store_id'], ['menu_name' => $configNmae, 'store_id' => $storeId])->value('value');
- }
-
- public function getConfigAll(array $configName = [], int $storeId = 0)
- {
- if ($configName) {
- return $this->withSearchSelect(['menu_name', 'store_id'], ['menu_name' => $configName, 'store_id' => $storeId])->column('value', 'menu_name');
- } else {
- return $this->getModel()->column('value', 'menu_name');
- }
- }
-
- public function getConfigAllField(array $configName = [], int $storeId = 0, array $field = [])
- {
- return $this->withSearchSelect(['menu_name', 'store_id'], ['menu_name' => $configName, 'store_id' => $storeId])->column(implode(',', $field), 'menu_name');
- }
-
- public function getConfigList(array $where, int $page, int $limit)
- {
- return $this->search($where)->page($page, $limit)->order('sort desc,id desc')->select()->toArray();
- }
-
- public function getConfigTabAllList(int $tabId, int $status = 1, int $type = 1, int $relation_id = 0)
- {
- $where['tab_id'] = $tabId;
- if ($status == 1) $where['status'] = $status;
- if ($relation_id != 0) $where['is_store'] = 1;
- return $this->search($where)
- ->when(isset($relation_id) && $relation_id != 0, function ($query) use ($type, $relation_id) {
- $query->with(['storeConfig' => function ($querys) use ($type, $relation_id) {
- $querys->where('type', $type)->where('relation_id', $relation_id);
- }]);
- })
- ->order('sort desc')->select()->toArray();
- }
-
- public function getConfigAllListByWhere(array $where, int $type = 1, int $relation_id = 0, array $field = ['*'])
- {
- if ($relation_id != 0) $where['is_store'] = 1;
- return $this->search($where)->field($field)
- ->when(isset($relation_id) && $relation_id != 0, function ($query) use ($type, $relation_id) {
- $query->with(['storeConfig' => function ($querys) use ($type, $relation_id) {
- $querys->where('type', $type)->where('relation_id', $relation_id);
- }]);
- })
- ->order('sort desc')->select()->toArray();
- }
-
- public function getUploadTypeList(string $configName)
- {
- return $this->search(['menu_name' => $configName])->column('upload_type', 'type');
- }
- }
|