AdminConfigController.php
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author:kane < chengjin005@163.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\AdminBaseController;
use think\Db;
class AdminConfigController extends AdminBaseController
{
public function index()
{
$data=Db::name('config')->where('id',1)->find();
$data['index_banner']=json_decode($data['index_banner'],'true');
$this->assign('list',$data);
return $this->fetch();
}
public function editPost(){
$param=$this->request->param();
if (!empty($param['photo_names']) && !empty($param['photo_urls'])) {
$param['index_banner']['photos'] = [];
foreach ($param['photo_urls'] as $key => $url) {
$photoUrl = cmf_asset_relative_url($url);
array_push($param['index_banner']['photos'], ["url" => $photoUrl, "name" => $param['photo_names'][$key]]);
}
unset($param['photo_urls']);
unset($param['photo_names']);
$param['index_banner']=json_encode($param['index_banner']);
}
$re=Db::name('config')->where('id',1)->update($param);
if ($re){
$this->success('编辑成功');
}else{
$this->error('编辑失败');
}
}
}