摘要:系统模块比较简单,只有一个界面,编辑即是展示页面<?php namespace app\admin\model; use think\Model; class System extends Model { //表名 protected
系统模块比较简单,只有一个界面,编辑即是展示页面
<?php
namespace app\admin\model;
use think\Model;
class System extends Model
{
//表名
protected $table = 'system';
//主键
protected $pk = 'id';
}控制器文件
<?php
namespace app\admin\controller;
use app\admin\common\Common;
use think\facade\Request;
use app\admin\model\System as SystemModel;
class System extends Common
{
public function index()
{
//获取原始信息通过id
$data = SystemModel::get(1);
//模板赋值
$this->view->assign('system',$data);
//渲染系统设置模板
return $this->view->fetch();
}
public function doEdit()
{
//获取提交过来的数据
$data = Request::param();
$id = $data['id'];
if(!$id){
return ['res'=>0,'msg'=>'非法操作'];
}
//更新数据
$res = SystemModel::update($data,['id',$data['id']]);
//判断是否成功更新
if($res){
return ['res'=>1,'msg'=>'修改成功'];
}else{
return ['res'=>2,'msg'=>'修改失败'];
}
}
}
批改老师:韦小宝批改时间:2018-12-25 09:18:40
老师总结:写的还是很不错的,简洁一眼能懂!挺好!后面项目写完记得没事的时候开发个个人博客还是很有意思的!