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

控制器代碼如下

原創(chuàng) 2019-06-14 10:04:54 406
摘要:<?php namespace app\index\controller; use app\admin\model\NewsModel; use app\admin\model\ProductModel; use app\admin\model\SystemModel; use think\Controller; use thin
<?php

namespace app\index\controller;
use app\admin\model\NewsModel;
use app\admin\model\ProductModel;
use app\admin\model\SystemModel;
use think\Controller;
use think\facade\Request;

class Index extends Controller
{
    

    public function about()
    {
        $system = new SystemModel();
        $systems = $system->select()->toArray();
        $this->view->systems = $systems;
        // 渲染首頁(yè)模板
        return $this->fetch();
    }

    public function product()
    {
        $product = new ProductModel();
        $products = $product->order('id','desc')->paginate(4);
        $this->view->products=$products;
        // 首頁(yè)模板
        return $this->fetch();
    }

    public function news()
    {
        // 實(shí)例化模型
        $new = new NewsModel();
        // 查詢數(shù)據(jù)按照id的順序查詢并且每頁(yè)四條數(shù)據(jù)
        $news = $new->order('id','desc')->paginate(4);
        // 賦值
        $this->view->news=$news;

        $hotNew = $new->limit(1)->select()->toArray();
        $this->view->hotNews = $hotNew;

        $newNews = $new->limit(6)->select()->toArray();
        $this->view->newNews=$newNews;
        // 渲染首頁(yè)模板
        return $this->fetch();
    }

    public function ConNew()
    {
        $newId = Request::param('id');
        // 查詢對(duì)應(yīng)的新聞詳細(xì)
        $new = NewsModel::get($newId);
        $this->view->new= $new;

        $hotNew = $new->limit(1)->select()->toArray();
        $this->view->hotNews = $hotNew;

        $newNews = $new->limit(6)->select()->toArray();
        $this->view->newNews=$newNews;
        // 首頁(yè)模板
        return $this->fetch();
    }

    public function ConPro()
    {
        // 獲取產(chǎn)品id
        $ProId = Request::param('id');
        $product = ProductModel::get($ProId);
        $this->view->product=$product;
        // 渲染首頁(yè)模板
        return $this->fetch();
    }

}


批改老師:查無(wú)此人批改時(shí)間:2019-06-14 14:20:06
老師總結(jié):完成的不錯(cuò)。php的框架多學(xué)幾款,對(duì)以后工作有幫助。繼續(xù)加油

發(fā)布手記

熱門(mén)詞條