返回 前台模块查询赋...... 登陆

前台模块查询赋值操作

意外 2019-06-05 15:23:22 237
<?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();
    }

}


最新手记推荐

• 用composer安装thinkphp框架的步骤 • 省市区接口说明 • 用thinkphp,后台新增栏目 • 管理员添加编辑删除 • 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网