當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::afterSave方法代碼示例

本文整理匯總了PHP中dektrium\user\models\User::afterSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::afterSave方法的具體用法?PHP User::afterSave怎麽用?PHP User::afterSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dektrium\user\models\User的用法示例。


在下文中一共展示了User::afterSave方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($insert) {
         UcenterUtil::register($this->username, $this->password, $this->email);
     }
 }
開發者ID:buuug7,項目名稱:game4039,代碼行數:7,代碼來源:User.php

示例2: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (!\Yii::$app instanceof ConsoleApplication) {
         if ($this->scenario == 'update' || $this->scenario == 'create') {
             $auth = new DbManager();
             $auth->init();
             $name = $this->role ? $this->role : self::ROLE_DEFAULT;
             $role = $auth->getRole($name);
             if (!$insert) {
                 $auth->revokeAll($this->id);
             }
             $auth->assign($role, $this->id);
         }
     }
 }
開發者ID:lenarx,項目名稱:yii2-cms-app-full,代碼行數:16,代碼來源:User.php

示例3: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $auth = Yii::$app->authManager;
     if ($insert) {
         $location = new \common\models\Locations();
         //$location->scenario = \common\models\Locations::SCENARIO_REGISTER;
         if ($location->load(Yii::$app->request->post())) {
             $location->user_id = $this->id;
             if ($location->save()) {
                 // USER CREDIT
                 $userCredit = new \common\models\UserCredit();
                 $userCredit->user_id = $this->id;
                 $userCredit->time = date('Y-m-d H:i:s');
                 $userCredit->save();
                 // USER DETAILS
                 $userDetails = new \common\models\UserDetails();
                 $userDetails->user_id = $this->id;
                 $userDetails->loc_id = $location->id;
                 $userDetails->file_id = 2;
                 $userDetails->lang_code = 'SR';
                 $userDetails->currency_id = 1;
                 $userDetails->role_id = 1;
                 $userDetails->time_role_set = date('Y-m-d H:i:s');
                 $userDetails->update_time = date('Y-m-d H:i:s');
                 $userDetails->save();
                 // USER LOCATIONS
                 $user_location = new \common\models\UserLocations();
                 $user_location->loc_id = $location->id;
                 $user_location->user_id = $this->id;
                 $user_location->save();
                 // USER LOG
                 $userLog = new \common\models\UserLog();
                 $userLog->user_id = $this->id;
                 $userLog->action = $this->is_provider == 0 ? 'user_registered' : 'provider_registered';
                 $userLog->alias = $this->id;
                 $userLog->time = date('Y-m-d H:i:s');
                 $userLog->save();
                 // USER NOTIFICATONS
                 $userNotifications = new \common\models\UserNotifications();
                 $userNotifications->user_id = $this->id;
                 $userNotifications->update_time = date('Y-m-d H:i:s');
                 $userNotifications->save();
                 if ($this->is_provider == 1) {
                     $model = new \common\models\RegistrationProviderForm();
                     if ($model->load(Yii::$app->request->post())) {
                         // PROVIDER
                         $provider = new \common\models\Provider();
                         $provider->user_id = $this->id;
                         $provider->industry_id = $model->industry;
                         $provider->loc_id = $location->id;
                         $provider->legal_form = 'freelancer';
                         $provider->type = 'service_provider';
                         $provider->department_type = 'hq';
                         $provider->status = 'active';
                         $provider->registration_time = date('Y-m-d H:i:s');
                         $provider->save();
                         $userRole = $auth->getRole('provider');
                         $auth->assign($userRole, $this->id);
                     }
                 } else {
                     $userRole = $auth->getRole('user');
                     $auth->assign($userRole, $this->id);
                 }
             }
         }
     } else {
         $this->updated_at = time();
     }
 }
開發者ID:bokko79,項目名稱:servicemapp,代碼行數:70,代碼來源:User.php

示例4: afterSave

 /** @inheritdoc */
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         $profile = \Yii::createObject(['class' => Profile::className(), 'user_id' => $this->id, 'gravatar_email' => $this->email]);
         $profile->save(false);
     }
     parent::afterSave($insert, $changedAttributes);
 }
開發者ID:poykub,項目名稱:wph,代碼行數:9,代碼來源:User.php

示例5: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (($auth = Yii::$app->authManager) !== null) {
         $participant = $auth->getRole('participant');
         if ($participant !== null) {
             $auth->assign($participant, $this->id);
         }
     }
     return true;
 }
開發者ID:svd222,項目名稱:blog,代碼行數:11,代碼來源:User.php


注:本文中的dektrium\user\models\User::afterSave方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。