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

前臺新聞模塊內(nèi)容

Original 2019-04-08 17:19:31 208
abstract:<?phpnamespace app\index\controller;use app\admin\model\NewsModel;use app\admin\model\ProductModel;use think\Controller;use think\Db;use think\facade\Request;class Index extends Controller{  

<?php
namespace app\index\controller;
use app\admin\model\NewsModel;
use app\admin\model\ProductModel;
use think\Controller;
use think\Db;
use think\facade\Request;

class Index extends Controller
{
   //渲染頁面模板
   public function index()
   {
       //輪播圖數(shù)據(jù)
       $data['banner']=Db::table('slide')->select();
       //頭牌數(shù)據(jù)
       $data['hot']=ProductModel::where('sort',1)->all();
       //新上花魁數(shù)據(jù)
       $data['flower']=ProductModel::where('sort',3)->find();
       //新聞
       $data['news']=NewsModel::limit(4)->all();
       return $this->fetch('',$data);
   }
   //渲染關(guān)于我們頁面
   public function about()
   {
       $about=Db::table('system')->find();
       $this->view->about=$about;
       return $this->fetch();
   }
   //渲染產(chǎn)品頁面
   public function product()
   {
       $data['product']=ProductModel::paginate(4);
       return $this->fetch('',$data);
   }
   //渲染新聞頁面
   public function news()
   {
       $data=NewsModel::order('id','desc')->paginate(4);
       $this->view->data=$data;
       //熱門新聞
       $hotNew=NewsModel::order('id','desc')->limit(1)->select();
       $this->view->hotNew=$hotNew;
       //最新發(fā)布
       $news =NewsModel::limit(4)->select();
       $this->view->news=$news;
       return $this->fetch();
   }
   //產(chǎn)品詳細
   public function  ConPro()
   {
       $id = Request::param('id');
       $detail = ProductModel::get($id);
       $this->view->detail=$detail;
       return $this->fetch();
   }
   //新聞詳細
   public function  ConNew()
   {
       $hotNew=NewsModel::order('id','desc')->limit(1)->select();
       $this->view->hotNew=$hotNew;
       //最新發(fā)布
       $news =NewsModel::limit(4)->select();
       $this->view->news=$news;
       //新聞詳細內(nèi)容
       $id = Request::param('id');
       $detail = NewsModel::get($id);
       $this->view->detail=$detail;
       return $this->fetch();
   }

}

總結(jié):通過本套課程,讓我了解了tp5框架的運行原理,以及如何使用這個框架和如何去開發(fā)一個項目。但是有的具體的使用還需多多練習(xí)項目才行

Correcting teacher:西門大官人Correction time:2019-04-09 10:25:02
Teacher's summary:孰能生巧,光看不練,一切都會歸零。加油。

Release Notes

Popular Entries