yii\db\BaseActiveRecord::afterSave PHP Метод

afterSave() публичный Метод

The default implementation will trigger an [[EVENT_AFTER_INSERT]] event when $insert is true, or an [[EVENT_AFTER_UPDATE]] event if $insert is false. The event class used is [[AfterSaveEvent]]. When overriding this method, make sure you call the parent implementation so that the event is triggered.
public afterSave ( boolean $insert, array $changedAttributes )
$insert boolean whether this method called while inserting a record. If `false`, it means the method is called while updating a record.
$changedAttributes array The old values of attributes that had changed and were saved. You can use this parameter to take action based on the changes made for example send an email when the password had changed or implement audit trail that tracks all the changes. `$changedAttributes` gives you the old attribute values while the active record (`$this`) has already the new, updated values. Note that no automatic type conversion performed by default. You may use [[\yii\behaviors\AttributeTypecastBehavior]] to facilitate attribute typecasting. See http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#attributes-typecasting.
    public function afterSave($insert, $changedAttributes)
    {
        $this->trigger($insert ? self::EVENT_AFTER_INSERT : self::EVENT_AFTER_UPDATE, new AfterSaveEvent(['changedAttributes' => $changedAttributes]));
    }