Created
January 27, 2016 14:54
-
-
Save pebriana/9cb1512661a617a7ca0f to your computer and use it in GitHub Desktop.
yii2 after save
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function afterSave($insert, $changedAttributes) | |
| { | |
| if (($this->scenario == 'user' || $this->scenario == 'guest') && $this->isNewRecord) | |
| \Yii::$app->mailer->compose('new_comment', ['model' => $this]) | |
| ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo(Email::getByGroup(Email::COMMENTS)) | |
| ->setSubject('Some subject') | |
| ->send(); | |
| parent::afterSave($insert, $changedAttributes); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment