Commit 429f17c19a355257a1ee8b4d97b292ca49f37c95

Authored by Administrator
1 parent d4c9a267

проапдейтил роли

common/models/Customer.php
... ... @@ -74,12 +74,7 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac
74 74 ->exists())
75 75 $this->addError('username','Такой пользователь уже есть.');
76 76 }
77   -
78   - public function sendMsg(){
79 77  
80   - Mailer::widget(['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]);
81   -
82   - }
83 78  
84 79 public function afterSave($insert, $changedAttributes)
85 80 {
... ... @@ -93,30 +88,28 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac
93 88 }
94 89 $auth->assign($role, $this->id);
95 90  
96   - if($this->isNewRecord){
97   - $this->sendMsg();
98   - }
  91 +
99 92 }
100 93  
101 94 public function beforeSave($insert) {
102 95  
103 96  
104   - $this->date_time = new \yii\db\Expression('NOW()');
105   -
  97 + $this->date_time = new \yii\db\Expression('NOW()');
  98 +
106 99 /**
107   - if($image = UploadedFile::getInstance($this,'image')){
108   -
  100 + if($image = UploadedFile::getInstance($this,'image')){
  101 +
109 102 $this->deleteImage($this->old_image);
110 103 //$this->image = $image;
111 104 $this->image = time() . '_' . rand(1, 1000) . '.' . $image->extension;
112 105 $image->saveAs('upload/profile/'.$this->image);
113   -
  106 +
114 107 $resizeObj = new resize('upload/profile/'.$this->image);
115 108 $resizeObj -> resizeImage(240, 240, 'crop');
116 109 $resizeObj -> saveImage('upload/profile/ico/'.$this->image, 100);
117 110 }elseif(!empty($this->old_image)) $this->image = $this->old_image;
118   - **/
119   -
  111 + **/
  112 +
120 113 return parent::beforeSave($insert);
121 114 }
122 115  
... ...
frontend/controllers/RegController.php
... ... @@ -2,6 +2,7 @@
2 2  
3 3 namespace frontend\controllers;
4 4  
  5 +use common\components\Mailer;
5 6 use Yii;
6 7 use yii\web\Controller;
7 8 use yii\filters\AccessControl;
... ... @@ -57,6 +58,7 @@ class RegController extends Controller
57 58 $modelLogin->username = $model->username;
58 59 $modelLogin->password = $model->password;
59 60 $modelLogin->login();
  61 + Mailer::widget(['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]);
60 62 $this->redirect(['/iam']);
61 63 }
62 64  
... ...