abstract:<?phpnamespace app\admin\controller;//use think\facade\View; //view创建静态代理use app\admin\model\SystemModel;use think\Controller;use app\admin\controller\Common;//访问入口use think\facade\Request;//
<?php
namespace app\admin\controller;
//use think\facade\View; //view创建静态代理
use app\admin\model\SystemModel;
use think\Controller;
use app\admin\controller\Common;//访问入口
use think\facade\Request;//系统控制器
use think\facade\Session;//系统缓存
class System extends Common
{
public function index()
{
//获取网站原始信息
$data = SystemModel::get(1);
//给模板赋值
$this->view->system = $data;
//渲染管理员界面
return $this->fetch();
}
public function DoEdit()
{
//获取提交的数据
$data = Request::param();
//实例化模型
$system = new SystemModel();
//修改数据
$info = $system->save([
'site_name'=>$data['site_name'],
'about_title'=>$data['about_title'],
'about_content'=>$data['about_content'],
'desc_title'=>$data['desc_title'],
'desc_content'=>$data['desc_content'],
'publicity_title'=>$data['publicity_title'],
'publicity_content'=>$data['publicity_content']
],['id'=>1]);
if($info){
return['res'=>1,'msg'=>'保存成功!'];
}else{
return['res'=>0,'msg'=>'保存失败!'];
}
}
}
Correcting teacher:查无此人Correction time:2019-06-20 09:49:40
Teacher's summary:完成的不错。如果$data可以直接使用,就不要在赋值了。继续加油。