Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MirAd::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'ad_rank' => $this->ad_rank]);
     $query->andFilterWhere(['like', 'ad_picture', $this->ad_picture])->andFilterWhere(['like', 'ad_desc', $this->ad_desc])->andFilterWhere(['like', 'ad_url', $this->ad_url])->orderby('id desc');
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function actionIndex()
 {
     $classifyModel = new Classify();
     $dafenlei = $classifyModel->find()->where(["ParentID" => '0'])->limit(8)->all();
     // p($dafenlei);
     $articleModel = new MirArticle();
     $jobs = $articleModel->articleToIndex(5);
     //技术分享
     $jishus = $articleModel->articleToIndex(3);
     $productModel = new MirProduct();
     //ivd 五个广告图
     $adModel = new MirAd();
     $ads = $adModel->find()->orderBy("ad_rank desc,id desc")->limit(5)->all();
     // p($ads);
     // p($fourPic);
     // P($ivdList);
     // p(count($ivdList));
     //产品照片显示
     $mainClass = $productModel->mainClass();
     foreach ($mainClass as $k => $v) {
         $mainClassId[] = $k;
     }
     for ($i = 0; $i < count($mainClassId) - 1; $i++) {
         $products[] = MirProduct::find()->where(['product_mainclass' => $mainClassId[$i]])->orderBy("product_rank desc,product_id desc")->limit(9)->all();
         $data = $productModel->find()->where(["product_mainclass" => $mainClassId[$i]]);
         $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '10']);
         $dataShow = $data->offset($pages->offset)->limit($pages->limit)->orderBy("product_rank desc,product_id desc")->all();
         $pagesArray[] = $pages;
         $productArray[] = $dataShow;
     }
     // p(count($products[1]));
     // p($pagesArray);
     // p($productArray);
     $mainClass = array_values($mainClass);
     return $this->render('index', ['dafenlei' => $dafenlei, 'jobs' => $jobs, 'jishus' => $jishus, 'ivdList' => $ivdList, 'mainClass' => $mainClass, 'products' => $products, 'productArray' => $productArray, 'pagesArray' => $pagesArray, 'ads' => $ads]);
 }
Ejemplo n.º 3
0
 /**
  * Finds the MirAd model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MirAd the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MirAd::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }