如果沒有與其中一個型號一個控制器yii2,例如,只有輪廓:模型返回afterSave yii2
class MyController class extends Controller {
public function actionCreate() {
$valid = $model->validate();
}
}
需要從aftersave的回報,這是指示消息,如果電子郵件能發送與否,並插入所有屬性。
afterSave模型:
public function afterSave($insert, $changedAttributes) {
if(!$this->isNewRecord) {
try {
Yii::$app->mailer->compose()
// email composition here
->send();
return 'mail sent';
catch (\Swift_SwiftException $exception) {
return 'email undeliverable'. $exception->getMessage();
}
}
}
可以從afterSave返回通過控制器來訪問?