diff --git a/common/models/Customer.php b/common/models/Customer.php index f4ae1f4..33e935e 100755 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -74,12 +74,7 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac ->exists()) $this->addError('username','Такой пользователь уже есть.'); } - - public function sendMsg(){ - Mailer::widget(['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]); - - } public function afterSave($insert, $changedAttributes) { @@ -93,30 +88,28 @@ class Customer extends \yii\db\ActiveRecord implements \yii\web\IdentityInterfac } $auth->assign($role, $this->id); - if($this->isNewRecord){ - $this->sendMsg(); - } + } public function beforeSave($insert) { - $this->date_time = new \yii\db\Expression('NOW()'); - + $this->date_time = new \yii\db\Expression('NOW()'); + /** - if($image = UploadedFile::getInstance($this,'image')){ - + if($image = UploadedFile::getInstance($this,'image')){ + $this->deleteImage($this->old_image); //$this->image = $image; $this->image = time() . '_' . rand(1, 1000) . '.' . $image->extension; $image->saveAs('upload/profile/'.$this->image); - + $resizeObj = new resize('upload/profile/'.$this->image); $resizeObj -> resizeImage(240, 240, 'crop'); $resizeObj -> saveImage('upload/profile/ico/'.$this->image, 100); }elseif(!empty($this->old_image)) $this->image = $this->old_image; - **/ - + **/ + return parent::beforeSave($insert); } diff --git a/frontend/controllers/RegController.php b/frontend/controllers/RegController.php index d47acc7..f5466a9 100755 --- a/frontend/controllers/RegController.php +++ b/frontend/controllers/RegController.php @@ -2,6 +2,7 @@ namespace frontend\controllers; +use common\components\Mailer; use Yii; use yii\web\Controller; use yii\filters\AccessControl; @@ -57,6 +58,7 @@ class RegController extends Controller $modelLogin->username = $model->username; $modelLogin->password = $model->password; $modelLogin->login(); + Mailer::widget(['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]); $this->redirect(['/iam']); } -- libgit2 0.21.4