Ejemplo n.º 1
0
 protected function findModel($id)
 {
     if (($model = Faq::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFaq()
 {
     return $this->hasOne(Faq::className(), ['id' => 'faq_id']);
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFaqs()
 {
     return $this->hasMany(Faq::className(), ['id' => 'faq_id'])->viaTable('faq_subject', ['faq_subject_id' => 'id']);
 }
Ejemplo n.º 5
0
 public function actionFaq()
 {
     return $this->render('faq', ['list' => Faq::find()->where(['active' => 1])->orderBy('id asc')->all(), 'subjects' => Subject::find()->all()]);
 }