Пример #1
0
 protected function findModel($id)
 {
     if (($model = Faq::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрашиваемая страница не найдена');
     }
 }
Пример #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]);
     $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->joinWith('faqType');
     $query->andFilterWhere(['faq_id' => $this->faq_id]);
     $query->andFilterWhere(['like', 'question', $this->question])->andFilterWhere(['like', 'answer', $this->answer])->andFilterWhere(['like', 'faqtype.type', $this->faq_type_id]);
     return $dataProvider;
 }
Пример #3
0
 public function search($params)
 {
     $query = Faq::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['faq_weight' => SORT_ASC], 'attributes' => ['id', 'faq_question' => ['asc' => ['faq.faq_question' => SORT_ASC], 'desc' => ['faq.faq_question' => SORT_DESC], 'label' => 'Вопрос'], 'faq_answer' => ['asc' => ['faq.faq_answer' => SORT_ASC], 'desc' => ['faq.faq_answer' => SORT_DESC], 'label' => 'Ответ'], 'faqCategoryName' => ['asc' => ['faq_category.faq_category_name' => SORT_ASC], 'desc' => ['faq_category.faq_category_name' => SORT_DESC], 'label' => 'Категория'], 'faq_weight' => ['asc' => ['faq.faq_weight' => SORT_ASC], 'desc' => ['faq.faq_weight' => SORT_DESC], 'label' => 'Приоритет от 1 до 100'], 'faqIsFeaturedName' => ['asc' => ['faq.faq_is_featured' => SORT_ASC], 'desc' => ['faq.faq_is_featured' => SORT_DESC], 'label' => 'Опубликовано?']]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['faqCategory']);
         return $dataProvider;
     }
     $this->addSearchParameter($query, 'id');
     $this->addSearchParameter($query, 'faq_category_id');
     $this->addSearchParameter($query, 'faq_weight');
     $this->addSearchParameter($query, 'faq_is_featured');
     $this->addSearchParameter($query, 'created_by');
     $this->addSearchParameter($query, 'updated_by');
     $this->addSearchParameter($query, 'faq_question', true);
     $this->addSearchParameter($query, 'faq_answer', true);
     $query->joinWith(['faqCategory' => function ($q) {
         $q->andFilterWhere(['=', 'faq_category.faq_category_name', $this->faqCategoryName]);
     }]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Finds the Faq model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Faq the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Faq::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFaqs()
 {
     return $this->hasMany(Faq::className(), ['faq_type_id' => 'faq_type_id']);
 }
Пример #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getFaqs()
 {
     return $this->hasMany(Faq::className(), ['faq_category_id' => 'id']);
 }