public function actionGetMentor($ent_id) { $ent = Entrepreneur::findOne($ent_id); $results = $ent->mentors; foreach ($results as $key => $value) { echo "user_id:" . $value->user_id . "\n"; echo "username:"******"\n"; } }
/** * Signs user up. * * @return User|null the saved model or null if saving fails */ public function signup() { if ($this->validate()) { $user = new User(); $user->username = $this->username; $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); if ($user->save()) { $profile = new Profile(); $profile->loadDefaultValues(); $profile->first_name = $this->first_name; $profile->last_name = $this->last_name; $profile->dob = $this->dob; $profile->address = $this->address; $profile->address2 = $this->address2; $profile->district = $this->district; $profile->state = $this->state; $profile->mobile = $this->mobile; $profile->ic = $this->ic; $profile->postcode = $this->postcode; $profile->name = $this->name; $profile->link('user', $user); if ($this->role == 'ENT') { $ent = new Entrepreneur(); $ent->plkn = $this->plkn; $ent->link('user', $user); } elseif ($this->role == 'MNT') { $mnt = new Mentor(); $mnt->link('user', $user); } Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo($user->email)->setSubject('SALEXES Registration')->setTextBody('Congratulations you have been succesfully registered with us !!!')->setHtmlBody('<b>Please contact admin@9teraju.com to make payment for account activation.</b>')->send(); return $user; } } return null; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Entrepreneur::find(); $query->joinWith(['user', 'profile']); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['username'] = ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC]]; $dataProvider->sort->attributes['email'] = ['asc' => ['user.email' => SORT_ASC], 'desc' => ['user.email' => SORT_DESC]]; $dataProvider->sort->attributes['name'] = ['asc' => ['profile.name' => SORT_ASC], 'desc' => ['profile.name' => SORT_DESC]]; $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(['like', 'profile.name', $this->name])->andFilterWhere(['like', 'profile.user_id', $this->user_id])->andFilterWhere(['like', 'user.email', $this->email]); $query->andFilterWhere(['like', 'plkn', $this->plkn]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getEntrepreneurUsers() { return $this->hasMany(Entrepreneur::className(), ['user_id' => 'entrepreneur_user_id'])->viaTable('{{%entp_invoice}}', ['invoice_id' => 'id']); }
/** * Finds the Entrepreneur model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Entrepreneur the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Entrepreneur::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getEntrepreneurs() { return $this->hasMany(Entrepreneur::className(), ['user_id' => 'entrepreneur_id'])->viaTable('{{%entp_supplier}}', ['supplier_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getEntrepreneurUser() { return $this->hasOne(Entrepreneur::className(), ['user_id' => 'entrepreneur_user_id']); }
/** * @return \yii\db\ActiveQuery */ public function getEntrepreneurs() { return $this->hasMany(Entrepreneur::className(), ['user_id' => 'entrepreneur_user_id'])->viaTable('{{%mentor_entrepreneur}}', ['mentor_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getEntrepreneurs() { return $this->hasMany(Entrepreneur::className(), ['id' => 'entrepreneur_id'])->viaTable('{{%entp_expenses}}', ['expenses_id' => 'id']); }