AboutUsController.php 1.7 KB
<?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("保存成功!");
    }
}