public function actionIntro()
 {
     $post = new Post();
     $intro = $post->getIntro();
     $sender['post'] = $intro;
     return $this->render('intro', $sender);
 }
Exemplo n.º 2
0
 public function actionCreatepost()
 {
     if (\Yii::$app->user->isGuest) {
         return $this->run('site/login');
     }
     $post = new Post();
     $data = \Yii::$app->request->post("Post");
     if (!empty($data)) {
         $post->load(\Yii::$app->request->post());
     }
     if (!empty($data) && $post->validate() && $post->save()) {
         return $this->render('create_post_success', ['post' => $post]);
     } else {
         return $this->render('create_post', ['post' => $post, 'categoryList' => Category::getList()]);
     }
 }
Exemplo n.º 3
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.º 4
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.º 5
0
 /**
  * Finds the Post model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Post the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 public function findModel($id)
 {
     if (($model = Post::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 6
0
 public function getPost()
 {
     return $this->hasMany(Post::className(), ['page_id' => 'id'])->orderBy('post.sort_order asc');
 }
Exemplo n.º 7
0
 public function actionShow($title)
 {
     $post = \frontend\models\Post::findOne(['title' => $title]);
     return $this->render('/site/show_post', ['model' => $post]);
 }
Exemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPost()
 {
     return $this->hasOne(Post::className(), ['id' => 'post_id']);
 }
Exemplo n.º 9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPosts()
 {
     return $this->hasMany(Post::className(), ['author_id' => 'id']);
 }
Exemplo n.º 10
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.º 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPost()
 {
     return $this->hasOne(Post::className(), ['kategory_forum' => 'id']);
 }
Exemplo n.º 12
0
 /**
  * Возвращает опубликованные посты
  * @return ActiveDataProvider
  */
 function getPublishedPosts()
 {
     return new ActiveDataProvider(['query' => Post::find()->where(['publish_status' => self::STATUS_PUBLISH])]);
 }
Exemplo n.º 13
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Post::find(), 'pagination' => ['pageSize' => 10]]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Exemplo n.º 14
0
 public function getCare()
 {
     $result = Post::find()->where(['group_post' => 3, 'status' => 1])->all();
     return $result;
 }