protected function findModel($id) { if (($model = Faq::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Faq::find(); $dataProvider = new ActiveDataProvider(['query' => $query->where(['status' => [Status::STATUS_ACTIVE, Status::STATUS_INACTIVE]])]); $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, 'faq_order' => $this->faq_order, 'is_disabled' => $this->is_disabled, 'status' => $this->status, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date]); $query->andFilterWhere(['like', 'question', $this->question])->andFilterWhere(['like', 'answer', $this->answer])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'modified_by', $this->modified_by]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getFaq() { return $this->hasOne(Faq::className(), ['id' => 'faq_id']); }
/** * @return \yii\db\ActiveQuery */ public function getFaqs() { return $this->hasMany(Faq::className(), ['id' => 'faq_id'])->viaTable('faq_subject', ['faq_subject_id' => 'id']); }
public function actionFaq() { return $this->render('faq', ['list' => Faq::find()->where(['active' => 1])->orderBy('id asc')->all(), 'subjects' => Subject::find()->all()]); }