/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Pinglun::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]); $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, 'star' => $this->star, 'type' => $this->type, 'rid' => $this->rid, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public function actionIndex() { //轮播图 $slider = Slider::find()->where(['place' => 0])->orderBy(['ord' => SORT_ASC])->all(); //微课 $weike = \common\models\Video::find()->where(['and', ['status' => \common\models\Status::STATUS_REC]])->limit(6)->all(); //教案 $jiaoan = \common\models\Resource::find()->where(['and', ['type' => 0], ['status' => \common\models\Status::STATUS_REC]])->limit(3)->all(); //课件 $kejian = \common\models\Resource::find()->where(['and', ['type' => 1], ['status' => \common\models\Status::STATUS_REC]])->limit(3)->all(); //试题 $shiti = \common\models\Resource::find()->where(['and', ['type' => 2], ['status' => \common\models\Status::STATUS_REC]])->limit(3)->all(); //新闻公告 $news = \common\models\News::find()->where(['and', 'status>' . \common\models\Status::STATUS_INACTIVE])->orderBy(['id' => SORT_DESC])->limit(3)->all(); //推荐下载 $recdown = \common\models\Resource::find()->where(['and', ['status' => \common\models\Status::STATUS_REC]])->orderBy(['id' => SORT_DESC])->limit(4)->all(); //最新评价 $pinglun = \common\models\Pinglun::find()->where(['and', 'status>' . \common\models\Status::STATUS_INACTIVE])->orderBy(['id' => SORT_DESC])->limit(6)->all(); //学霸必备 $xueba = \common\models\Resource::find()->where(['and', 'status>' . \common\models\Status::STATUS_REC])->orderBy(['rand()' => SORT_DESC])->limit(10)->all(); //友情链接 $friendLink = \common\models\Friendlink::find()->where(['isshow' => \common\models\YesNo::YES])->orderBy(['ord' => SORT_ASC])->all(); return $this->render('index', ['slider' => $slider, 'weike' => $weike, 'jiaoan' => $jiaoan, 'kejian' => $kejian, 'shiti' => $shiti, 'news' => $news, 'recdown' => $recdown, 'pinglun' => $pinglun, 'xueba' => $xueba, 'friendlink' => $friendLink]); }
public function actionComment($id, $type) { $this->layout = false; //查询评论信息 $query = Pinglun::find()->where(['type' => $type, 'rid' => $id]); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]], 'pagination' => ['pageSize' => 15]]); return $this->render('_comment', ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination]); }
public function actionPinglun() { $where[] = 'and'; $where[] = ['created_by' => Yii::$app->user->id]; $query = \common\models\Pinglun::find()->where($where); $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 8], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); return $this->render('pinglun', ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination]); }