Files
ntonpower/app/index/model/SystemConfig.php
2026-10-14 14:00:29 +08:00

78 lines
2.4 KiB
PHP

<?php
declare (strict_types = 1);
namespace app\index\model;
/**
* 系统配置
* @mixin \think\Model
*/
class SystemConfig extends BaseModel
{
protected $schema = [
'id' =>'int',
'platform_id' =>'int',
'language_id' =>'int',
'site_id' =>'int',
'type' =>'int',
'page' =>'string',
'pos' =>'string',
'name' =>'string',
'value' =>'string',
'image' =>'string',
'create_time' =>'int',
'update_time' =>'int'
];
/**
* 获取尾部信息
* @param $languageId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getFooterInfo($languageId):array
{
$result = $this->field(['name','value','image'])->where(['site_id'=>$languageId,'pos'=>'footer'])->select()->toArray();
if (!empty($result)) {
$newData = [];
foreach ($result as $value) {
if ($value['image']) {
$images = json_decode($value['image'],true);
$newData[$value['name']]['value'] = $value['value'] != '' ? $value['value'] : $images[0]['image'];
} else {
$newData[$value['name']]['value'] = '';
}
}
return $newData;
}
return [];
}
/**
* 获取尾部信息
* @param $languageId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getWebSiteInfo($languageId):array
{
$result = $this->field(['name','value','image'])->where(['site_id'=>$languageId,'pos'=>'index'])->select()->toArray();
if (!empty($result)) {
$newData = [];
foreach ($result as $value) {
if ($value['image']) {
$images = json_decode($value['image'],true);
$newData[$value['name']]['value'] = $value['value'] != '' ? $value['value'] : $images[0]['image'];
} else {
$newData[$value['name']]['value'] = '';
}
}
return $newData;
}
return [];
}
}