Exemplo n.º 1
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $kategory_forum = Yii::$app->session['forum_id'];
     $posting = Post::find()->where(['kategory_forum' => $kategory_forum])->all();
     $forum = Forum::find()->where(['id' => $kategory_forum])->one();
     $nama = "";
     foreach ($posting as $postings) {
         $nama = $postings->nama;
     }
     $usr = new \common\models\User();
     $fotoPost = $usr->find()->where(['nama' => $nama])->all();
     return $this->render('index', ['posting' => $posting, 'forum' => $forum, 'fotoPost' => $fotoPost]);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Post::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Post::find();
     $query->select('{{%post}}.*,{{%user}}.username');
     $query->joinWith(['author']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id' => ['asc' => ['{{%post}}.id' => SORT_ASC], 'desc' => ['{{%post}}.id' => SORT_DESC], 'label' => 'Id'], 'author_id' => ['asc' => ['{{%post}}.author_id' => SORT_ASC], 'desc' => ['{{%post}}.author_id' => SORT_DESC], 'label' => 'Author Id'], 'created_at' => ['asc' => ['{{%post}}.created_at' => SORT_ASC], 'desc' => ['{{%post}}.created_at' => SORT_DESC], 'label' => 'Created At'], 'title' => ['asc' => ['{{%post}}.title' => SORT_ASC], 'desc' => ['{{%post}}.title' => SORT_DESC], 'label' => 'Title'], 'username' => ['asc' => ['{{%user}}.username' => SORT_ASC], 'desc' => ['{{%user}}.username' => SORT_DESC], 'label' => 'UserName']]]);
     $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(['{{%post}}.id' => $this->id, '{{%post}}.author_id' => $this->author_id, '{{%post}}.created_at' => $this->created_at]);
     $query->andFilterWhere(['like', '{{%post}}.title', $this->title]);
     $query->andFilterWhere(['like', '{{%user}}.username', $this->username]);
     return $dataProvider;
 }
Exemplo n.º 4
0
<?php

$current = 0;
?>
<div class="pane latest-ads-holder">
        <?php 
echo \yii\widgets\ListView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \frontend\models\Post::find()->where(['category' => $category])->orderBy('created DESC'), 'pagination' => ['pageSize' => 9]]), 'itemView' => function ($model) use(&$current) {
    return $this->render('_post_item_grid', ['item' => $model, 'current' => $current]);
}, 'itemOptions' => ['class' => 'ad-box col-xs-3 latest-posts-grid' . ($current % 3 == 0 ? ' ' : '')], 'options' => ['class' => 'latest-ads-grid-holder'], 'summary' => '']);
?>
</div>
Exemplo n.º 5
0
 /**
  * Возвращает опубликованные посты
  * @return ActiveDataProvider
  */
 function getPublishedPosts()
 {
     return new ActiveDataProvider(['query' => Post::find()->where(['publish_status' => self::STATUS_PUBLISH])]);
 }
Exemplo n.º 6
0
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     return $this->render('index', ['posts' => Post::find()->all(), 'categories' => Category::find()->where(['parent' => 0])->all(), 'postsDataProvider' => new ActiveDataProvider(['query' => Post::find()])]);
 }
Exemplo n.º 7
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find(), 'pagination' => ['pageSize' => 10]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 8
0
 public function getCare()
 {
     $result = Post::find()->where(['group_post' => 3, 'status' => 1])->all();
     return $result;
 }
Exemplo n.º 9
0
 /**
  * Lists all Post models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }