Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Person::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(['user_id' => $this->user_id, 'department_id' => $this->department_id]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'photo', $this->photo])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'tel', $this->tel]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 public function myCustomUniquePerson($attribute)
 {
     $person = Person::find()->where(['!=', 'id', $this->id_person])->andWhere(['=', 'identity_type', $this['identity_type']])->andWhere(['=', 'identity_sequence', $this['identity_sequence']])->andWhere(['=', 'identity_number', $this['identity_number']])->one();
     if (!empty($person)) {
         $this->addError($attribute, 'Персона с данными аттрибутами уже зарегестрирована');
     }
 }