Example #1
0
 public function afterFind()
 {
     if (!empty($this->cluster_id)) {
         $this->cluster = ProjectClusters::findOne($this->cluster_id)['cluster'];
     }
     parent::afterFind();
 }
Example #2
0
 public function afterFind()
 {
     if ($this->getObservers()->exists()) {
         foreach ($this->getObservers()->all() as $observer) {
             $this->observers[$observer->id] = $observer->username;
         }
     }
     parent::afterFind();
 }
Example #3
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             $this->auth_key = \Yii::$app->security->generateRandomString();
         }
         return true;
     }
     return false;
 }
Example #4
0
 public function afterFind()
 {
     $this->entrances = ArrayHelper::map($this->boxtypeEntrances, 'entrance_index', 'entrance_index');
     parent::afterFind();
 }
Example #5
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;
 }
Example #6
0
 /** @inheritdoc */
 public function scenarios()
 {
     return ArrayHelper::merge(parent::scenarios(), [self::SCENARIO_CREATE => ['name', 'project_id'], self::SCENARIO_MODIFY => ['name']]);
 }
Example #7
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;
 }
Example #8
0
 /** @inheritdoc */
 public function scenarios()
 {
     return ArrayHelper::merge(parent::scenarios(), [self::SCENARIO_CREATE => ['name', 'description', 'owner_id', '!member_count', '!ticket_count', '!last_activity'], self::SCENARIO_MODIFY => ['name', 'description']]);
 }
Example #9
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;
 }