亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

分類管理模塊代碼

??? 2019-05-14 14:45:56 426
????:<?php /**  * Created by PhpStorm.  * User: Administrator  * Date: 2019/5/14  * Time: 13:03  */ namespace app\admin\control
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/14
 * Time: 13:03
 */
namespace app\admin\controller;

use app\admin\controller\Common;

use app\admin\model\SortModel;
use think\facade\Request;
use think\facade\Session;

class Sort extends Common
{
    public function index()
    {
        // 實(shí)例化模型
        $sort = new SortModel();
        // 查詢數(shù)據(jù)并按照id的順序
        $sorts = $sort->order('id', 'desc')->paginate(2);
        // 蔣數(shù)據(jù)賦值給模板
        $this->view->sorts = $sorts;
        // 渲染分類列表
        return $this->fetch();
    }

    public function DoAdd()
    {
        // 獲取提交過(guò)來(lái)的數(shù)據(jù)
        $data = Request::param();
        // 獲取添加數(shù)據(jù)
        $data['time'] = time();
        // 獲取發(fā)布管理員
        $data['username'] = Session::get('username');
        // 實(shí)例化模型
        $sort = new SortModel();
        // 存儲(chǔ)并驗(yàn)證
        if ($sort->save($data)) {
            // 返回對(duì)應(yīng)信息
            return ['res' => 1, 'msg' => '添加成功!'];
        } else {
            return ['res' => 0, 'msg' => '添加失?。?#39;];
        }
    }

    public function edit()
    {
        // 獲取需要修改的分類id
        $sortId = Request::param('id');
        // 使用分類的id查詢對(duì)應(yīng)的數(shù)據(jù)
        $sort = SortModel::get($sortId);
        // 將數(shù)據(jù)賦值給模板
        $this->view->sort = $sort;
        // 渲染修改界面
        return $this->fetch();
    }

    public function DoEdit()
    {
        // 獲取提交數(shù)據(jù)
        $data = Request::param();
        // 實(shí)例化模型
        $sort = new SortModel();
        // 修改更新操作
        $info = $sort->save([
            'sortname' => $data['sortname'],
            'time' => time(),
            'username' => Session::get('username'),
        ], ['id' => $data['id']]);
        // 驗(yàn)證修改結(jié)果
        if ($info) {
            // 返回對(duì)應(yīng)值
            return ['res' => 1, 'msg' => '修改成功!'];
        } else {
            return ['res' => 0, 'msg' => '修改失敗!'];
        }
    }

    public function del()
    {
        // 獲取需要?jiǎng)h除的分類id
        $sortId = Request::param('id');
        // 實(shí)例化模型
        $sort = new SortModel();
        // 刪除并驗(yàn)證
        if ($sort->destroy($sortId)) {
            return ['res'=>1,'msg'=>'刪除成功!'];
        }

    }
}


?? ???:查無(wú)此人?? ??:2019-05-15 14:00:39
???? ??:完成的不錯(cuò),后臺(tái)cms管理系統(tǒng),大多是用來(lái)管理數(shù)據(jù)庫(kù)。繼續(xù)加油。

??? ??

?? ??