init: 项目初始代码
This commit is contained in:
78
app/index/model/SystemConfig.php
Normal file
78
app/index/model/SystemConfig.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user