/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ValeBeneficiarios::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(['idvale_beneficiarios' => $this->idvale_beneficiarios]);
     $query->andFilterWhere(['like', 'beneficiario', $this->beneficiario]);
     return $dataProvider;
 }
Exemple #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getValeBeneficiariosIdvaleBeneficiarios()
 {
     return $this->hasOne(ValeBeneficiarios::className(), ['idvale_beneficiarios' => 'vale_beneficiarios_idvale_beneficiarios']);
 }
 public function actionListarRemoto($search = null, $id = null)
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $out = ['more' => false];
     if (!is_null($search)) {
         $query = new Query();
         $query->select('idvale_beneficiarios AS id, beneficiario AS text')->from('vale_beneficiarios')->where('beneficiario LIKE "%' . $search . '%"')->limit(20);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $out['results'] = ['id' => $id, 'text' => ValeBeneficiarios::findOne($id)->beneficiarios];
     }
     echo Json::encode($out);
 }