Exemple #1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             $this->auth_key = \Yii::$app->security->generateRandomString();
         }
         return true;
     }
     return false;
 }
Exemple #2
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord || is_null($this->number)) {
             $this->number = $this->visit->observation_counter + 1;
             $this->visit->observation_counter++;
             $this->visit->save();
         }
         return true;
     }
     return false;
 }
Exemple #3
0
 /** @inheritdoc */
 public function beforeSave($insert)
 {
     if (!parent::beforeSave($insert)) {
         return false;
     }
     if ($this->getScenario() == self::SCENARIO_CREATE) {
         $this->password_hash = (new Security())->generatePasswordHash($this->password);
     }
     return true;
 }
Exemple #4
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord || is_null($this->number)) {
             $this->number = $this->visit->observation_counter + 1;
             $this->visit->observation_counter++;
             $this->visit->save();
         }
         if (!$this->isNewRecord && (!empty($this->validated_by_id) || !empty($this->validated_date))) {
             if (!is_object(Yii::$app->user->getIdentity()) || !Yii::$app->user->getIdentity()->hasRole(['validator', 'administrator'])) {
                 $this->validated_by_id = NULL;
                 $this->validated_date = NULL;
             }
         }
         return true;
     }
     return false;
 }