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

前臺模塊查詢賦值操作

Original 2019-06-05 15:23:22 259
abstract:<?php namespace app\index\controller; use app\admin\model\NewsModel; use app\admin\model\ProductModel; use app\admin\model\SlideModel; use app\admin\model\SystemModel; use
<?php

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

class Index extends Controller
{
    public function index()
    {
        // 查詢輪播圖
        $slide = new SlideModel();
        $slides = $slide->select()->toArray();
        $this->view->slides = $slides;

        // 查詢頭牌
        $product = new ProductModel();
        $products = $product->where('sort','1')->select()->toArray();
        $this->view->products = $products;
        // 查詢新上花魁
        $NewProduct = $product->where('sort','2')->limit(1)->select()->toArray();
        $this->view->NewProduct = $NewProduct;

        // 查詢最新資訊
        $new = new NewsModel();
        $news = $new->limit(4)->select()->toArray();
        $this->view->news=$news;

        // 渲染首頁模板
        return $this->fetch();
    }

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

    public function product()
    {
        $product = new ProductModel();
        $products = $product->order('id','desc')->paginate(4);
        $this->view->products=$products;
        return $this->fetch();
    }

    public function news()
    {
        // 實例化模型
        $new = new NewsModel();
        $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;

        return $this->fetch();
    }

    public function ConNew()
    {
        $newId = Request::param('id');
        $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;
        return $this->fetch();
    }

    public function ConPro()
    {
        $ProId = Request::param('id');
        $product = ProductModel::get($ProId);
        $this->view->product=$product;
        return $this->fetch();
    }

}


Correcting teacher:查無此人Correction time:2019-06-06 09:19:26
Teacher's summary:完成的不錯。學(xué)編程,先從模仿開始,繼續(xù)加油。

Release Notes

Popular Entries