Esempio n. 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]);
 }
Esempio n. 2
0
 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]);
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 7
0
 public function actionDetails($id)
 {
     $post = Posts::find()->where(['id' => $id])->one();
     return $this->render('details', ['post' => $post]);
 }
Esempio n. 8
0
 public function actionPost()
 {
     $provider = new ActiveDataProvider(['query' => Posts::find()->orderBy('created_at DESC'), 'pagination' => ['pageSize' => 20]]);
     return $this->render('post', ['dataProvider' => $provider]);
 }
Esempio n. 9
0
 public function getPublishedPosts()
 {
     return new ActiveDataProvider(['query' => Posts::find()->where(['is_moderate' => self::IS_MODERATE])->orderBy(['create_date' => SORT_DESC])]);
 }