实现系统设置功能

Original 2019-03-12 01:58:42 305
abstract:<?php /**  * Created by PhpStorm.  * User: Administrator  * Date: 2019/3/2  * Time: 13:40  */ namespace app\admins\contro

QQ图片20181114103819.png

<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/2
 * Time: 13:40
 */

namespace app\admins\controller;
use app\admins\controller\Base;


class Site extends Base
{
    public function index()
    {
        $siteInfo = $this->db->table('setting')->where(['names'=>'site_setting'])->item();
        $siteInfo = json_decode($siteInfo['values'],true);
        $this->assign('siteInfo',$siteInfo);
        return $this->fetch();
    }

    public function save()
    {
        $names = trim(input('post.names'));
        $data['values'] = json_encode(input('post.values'));
        $siteInfo = $this->db->table('setting')->where(['names'=>$names])->item();
        if($siteInfo){
            $this->db->table('setting')->where(['names'=>$names])->update($data);
        }else{
            $data['names'] = $names;
            $this->db->table('setting')->insert($data);
        }
        return ['code'=>0,'msg'=>'保存成功'];
    }
}

QQ图片20181114103819.png

Correcting teacher:韦小宝Correction time:2019-03-12 09:28:33
Teacher's summary:写的没毛病 你这后台的颜色搭配的有点不到位哦

Release Notes

Popular Entries