Last active
May 19, 2021 10:05
-
-
Save ovicko/75e525c8784cb865c5be66cff4dac7a0 to your computer and use it in GitHub Desktop.
Attach the event handler in the init method of your ActiveRecord.
This file contains 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
<?php | |
class Records extends \yii\db\ActiveRecord | |
{ | |
const EVENT_SEND_EMAIL_UPDATE = 'send-email-to-users'; | |
public function init() | |
{ | |
// first parameter is the name of the event and second is the handler. | |
// sendMail method from $this class. | |
$this->on(self::EVENT_SEND_EMAIL_UPDATE, [$this, 'sendMail']); | |
parent::init(); // DON'T Forget to call the parent method. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment