/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Meme::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]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
<?php use yii\helpers\Html; use common\models\Category; use common\models\Tag; use common\models\Author; use common\models\Meme; use common\models\Vidmage; use common\helpers\Tools; $channels = Category::find()->all(); $tags = Tag::find()->orderBy(['recount' => SORT_DESC])->limit(10)->all(); $authors = Author::find()->orderBy(['recount' => SORT_DESC])->limit(5)->all(); $latestMemes = Meme::find()->orderBy(['id' => SORT_DESC])->limit(10)->all(); $latestReplicas = Vidmage::find()->joinWith('memeVidmages')->where(['meme_vidmage.is_the_origin' => false])->orderBy(['id' => SORT_DESC])->limit(10)->all(); ?> <?php echo $this->render('_left-column-list-items', ['items' => $latestMemes, 'title' => 'Latest Memes', 'icon' => 'globe', 'divId' => 'latest-memes', 'class' => 'success']); ?> <?php echo $this->render('_left-column-list-items', ['items' => $latestReplicas, 'title' => 'Latest Replicas', 'icon' => 'film', 'divId' => 'latest-replicas', 'class' => 'info']); ?> <?php echo $this->render('_left-column-list-items', ['items' => $channels, 'title' => 'Channels', 'icon' => 'blackboard', 'divId' => 'channels', 'class' => 'warning']); ?> <?php echo $this->render('_left-column-list-items', ['items' => $tags, 'title' => 'Trending Tags', 'icon' => 'tag', 'divId' => 'tags', 'class' => 'danger']); ?>
public function actionIndex() { $mostPopularMeme = Meme::mostPopular(); $newReplicas = Vidmage::find()->joinWith('memeVidmages')->where(['meme_vidmage.is_the_origin' => false])->orderBy(['id' => SORT_DESC])->limit(4)->all(); $editorMemePick = Meme::findOne(7); $newMemes = Meme::find()->joinWith('memeVidmages')->where(['meme_vidmage.is_the_origin' => true])->orderBy(['id' => SORT_DESC])->limit(4)->all(); return $this->render('index', compact('mostPopularMeme', 'newReplicas', 'editorMemePick', 'newMemes')); }