AdminAboutController.php
1.9 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
48
49
50
51
52
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use app\portal\model\AboutModel;
use app\portal\model\PortalPostModel;
use cmf\controller\AdminBaseController;
class AdminAboutController extends AdminBaseController
{
//关于我们
//编辑页面
public function edit(){
$aboutModel = new AboutModel();
$post = $aboutModel->where('id',1)->find();
$contentModel = new PortalPostModel();
$post['detail'] = $contentModel->getPostContentAttr($post['detail']);
$post['detail_en'] = $contentModel->getPostContentAttr($post['detail_en']);
$this->assign('post',$post);
return $this->fetch();
}
//编辑提交
public function editPost(){
$data = $this->request->param();
$result = $this->validate($data, 'AdminAbout.edit');
if ($result !== true) {
$this->error($result);
}
$aboutModel = new AboutModel();
// 显式指定更新数据操作
$contentModel = new PortalPostModel();
$data['detail'] = $contentModel->setPostContentAttr($data['detail']);
$data['detail_en'] = $contentModel->setPostContentAttr($data['detail_en']);
$res = $aboutModel->isUpdate(true)->save($data);
if($res){
$this->success('保存成功!');
}else{
$this->error('失败');
}
}
}