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