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