abstrakt:<?phpnamespace app\admin\controller;//use think\facade\View; //view創(chuàng)建靜態(tài)代理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創(chuàng)建靜態(tài)代理
use app\admin\model\SystemModel;
use think\Controller;
use app\admin\controller\Common;//訪問入口
use think\facade\Request;//系統(tǒng)控制器
use think\facade\Session;//系統(tǒng)緩存
class System extends Common
{
public function index()
{
//獲取網(wǎng)站原始信息
$data = SystemModel::get(1);
//給模板賦值
$this->view->system = $data;
//渲染管理員界面
return $this->fetch();
}
public function DoEdit()
{
//獲取提交的數(shù)據(jù)
$data = Request::param();
//實(shí)例化模型
$system = new SystemModel();
//修改數(shù)據(jù)
$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'=>'保存失?。?#39;];
}
}
}
Korrigierender Lehrer:查無此人Korrekturzeit:2019-06-20 09:49:40
Zusammenfassung des Lehrers:完成的不錯(cuò)。如果$data可以直接使用,就不要在賦值了。繼續(xù)加油。