AboutUsController.php
1.7 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
<?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\admin\controller;
use cmf\controller\AdminBaseController;
use app\admin\model\AboutUsModel;
use app\portal\model\PortalPostModel;
class AboutUsController extends AdminBaseController
{
protected $targets = ["_blank" => "新标签页打开", "_self" => "本窗口打开"];
//编辑页面
public function edit(){
$AboutUsModel = new AboutUsModel();
$about = $AboutUsModel->where('id',1)->find();
$contentModel = new PortalPostModel();
$about['content'] = $contentModel->getPostContentAttr($about['content']);
$this->assign('post', $about);
return $this->fetch();
}
//编辑保存页面
public function editPost(){
$data = $this->request->param();
$AboutUsModel = new AboutUsModel();
$result = $this->validate($data, 'AboutUs');
if ($result !== true) {
$this->error($result);
}
$contentModel = new PortalPostModel();
$data['content'] = $contentModel->setPostContentAttr($data['content']);
$AboutUsModel->allowField(true)->isUpdate(true)->save($data);
$this->success("保存成功!");
}
}