/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = CmsPages::find(); // add conditions that should always apply here $query->joinWith(['user']); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]); $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; } // grid filtering conditions $query->andFilterWhere(['page_id' => $this->page_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'username', $this->created_by])->andFilterWhere(['like', 'm_cms_pages.status', $this->status])->andFilterWhere(['like', 'menu_title', $this->menu_title]); return $dataProvider; }
/** * Finds the CmsPages model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return CmsPages the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = CmsPages::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getPage() { return $this->hasOne(CmsPages::className(), ['page_id' => 'page_id']); }
/** * Get all active cms pages * @return CmsPages the retrieved model */ public function getAllCmsPages() { return CmsPages::find()->select(['page_id', 'menu_title'])->where(['status' => '1'])->asArray()->all(); }