系统模板渲染,修改更新

Original 2019-05-28 21:39:43 236
abstract:<?php namespace app\admin\controller; use app\admin\controller\Common; use app\admin\model\SystemModel; use think\facade\Request; use think\facade\Session; class Syst
<?php
namespace app\admin\controller;
use app\admin\controller\Common;
use app\admin\model\SystemModel;
use think\facade\Request;
use think\facade\Session;

class System extends Common
{
public function index()
{
// 首页查询出数据
$res = SystemModel::all();
foreach($res as $val){
// 模板赋值
$this->view->assign('system',$val);
}
// 模板渲染
return $this->view->fetch();
}
public function edit()
{
// 系统更新
$data = Request::param();
$datas = [
'site_name' => $data['site_name'],
'about_title' => $data['about_title'],
'about_content' => $data['about_content'],
'com_int_title' => $data['com_int_title'],
'com_int_content' => $data['com_int_content'],
'com_x_title' => $data['com_x_title'],
'com_x_cont' => $data['com_x_cont'],
'time' => time(),
'username' => Session::get('username')
];
$res = SystemModel::where('id',1)->update($datas);
if($res){
return ['status' => 1,'msg' => '修改成功~~'];
}else{
return ['status' => 0,'msg' => '修改失败!'];
}
}
}


Correcting teacher:查无此人Correction time:2019-05-29 13:15:19
Teacher's summary:完成的不错。后台cms管理系统,就是对数据进行操作。操作越简单越好。继续加油。

Release Notes

Popular Entries