public function add() { $business_user = new Users(); $business_user->username = $this->username; $business_user->password = Yii::$app->security->generatePasswordHash($this->password); $business_user->email = $this->email; $business_user->mobile_phone = $this->mobile_phone; $business_user->comments = $this->comments; $business_user->social_role = self::BUSINESS_ROLE; $p_code = Users::find()->select("MAX(`pasport_code`)+1")->where(['social_role' => self::BUSINESS_ROLE])->scalar(); $business_user->pasport_code = $p_code ? $p_code : 1; $result = $business_user->save(); if ($result) { return $business_user; } else { return false; } }
/** * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne(Users::className(), ['id' => 'user_id']); }
/** * @return \yii\db\ActiveQuery */ public function getInternalUser() { return $this->hasOne(Users::className(), ['id' => 'internal_user']); }
/** * @return \yii\db\ActiveQuery */ public function getEconomicViewedUser() { return $this->hasOne(Users::className(), ['id' => 'economic_viewed_user_id']); }
/** * @return \yii\db\ActiveQuery */ public function getUsers() { return $this->hasMany(Users::className(), ['social_role_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getChild5() { return $this->hasOne(Users::className(), ['id' => 'child_5']); }