Example #1
0
 public function actionDetails($id)
 {
     //        $test = Posts::getTest();
     $query = Posts::findOne($id);
     $post = Posts::find()->where(['id' => $id])->one();
     return $this->render('details', ['post' => $post, 'query' => $query]);
 }
 public function actionOrders($category)
 {
     $query = Job::find()->where(['category_id' => $category]);
     $query2 = Posts::find()->where(['category_id' => $category]);
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $orders = $query->orderBy('create_date DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     $postOrders = $query2->orderBy('create_date DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('orders', ['orders' => $orders, 'pagination' => $pagination, 'postOrders' => $postOrders]);
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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, 'author' => $this->author, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Example #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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, 'create_date' => $this->create_date, 'author_id' => $this->author_id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'is_moderate', $this->is_moderate])->andFilterWhere(['like', 'author.name', $this->getAttribute('author.name')]);
     return $dataProvider;
 }
Example #5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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(['post_id' => $this->post_id, 'author_id' => $this->author_id]);
     $query->andFilterWhere(['like', 'post_title', $this->post_title])->andFilterWhere(['like', 'post_description', $this->post_description]);
     return $dataProvider;
 }
Example #6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Posts::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, 'post_category_id' => $this->post_category_id, 'status' => $this->status, 'published' => $this->published, 'time' => $this->time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'subtitle', $this->subtitle])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPost()
 {
     return $this->hasOne(Posts::className(), ['id' => 'post_id']);
 }
Example #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPosts()
 {
     return $this->hasMany(Posts::className(), ['post_category_id' => 'id']);
 }
Example #9
0
 /**
  * Finds the Posts model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Posts the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Posts::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #10
0
 public function actionPost()
 {
     $provider = new ActiveDataProvider(['query' => Posts::find()->orderBy('created_at DESC'), 'pagination' => ['pageSize' => 20]]);
     return $this->render('post', ['dataProvider' => $provider]);
 }
Example #11
0
 public function getPublishedPosts()
 {
     return new ActiveDataProvider(['query' => Posts::find()->where(['is_moderate' => self::IS_MODERATE])->orderBy(['create_date' => SORT_DESC])]);
 }