Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pregunta::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->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'codFormulario', $this->codFormulario])->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Lists all Pregunta models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Pregunta::find()->where(['eliminado' => 0])]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Esempio n. 3
0
 public function destroyPregunta($id)
 {
     try {
         $pre = Pregunta::find($id);
         $list = DB::table('respuesta')->where('pregunta', '=', $pre->id)->get();
         //return $list;
         if (!empty($list)) {
             foreach ($list as &$value) {
                 $res = Respuesta::find($value->id);
                 $res->delete();
             }
         }
         $pre->delete();
         return JsonResponse::create(array('message' => "Pregunta Eliminada Correctamente", "request" => json_encode($id)), 200);
     } catch (Exception $ex) {
         return JsonResponse::create(array('message' => "No se pudo Eliminar la pregunta", "exception" => $ex->getMessage(), "request" => json_encode($id)), 401);
     }
 }