Ejemplo n.º 1
0
 public function actionView()
 {
     if (User::isAdmin(Yii::$app->user->identity->username)) {
         $link = new ActiveDataProvider(['query' => Answers::find(), 'pagination' => ['pageSize' => 50]]);
         return $this->render('view', compact('link'));
     } else {
         throw new ForbiddenHttpException('У вас нет прав администратора!', 404);
     }
 }
Ejemplo n.º 2
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Answers::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, 'answer_num' => $this->answer_num, 'question' => $this->question, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'answer', $this->answer]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Answers::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'questions_id' => $this->questions_id, 'how_many' => $this->how_many]);
     $query->andFilterWhere(['like', 'answer', $this->answer]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 /**
  * Вывод новостей
  * @return string
  */
 public function actionIndex()
 {
     $news = Answers::find()->all();
     return $this->render('index', compact('news'));
 }