public function afterDelete()
    {
        // after complete owner delete delete tags links
        if (!empty($this->_tagsForDelete)) {
            $relation = $this->owner->getRelation('tagsList', false);
            if ($relation instanceof ActiveQuery) {
                /** @var ActiveRecord $class */
                $class = $relation->modelClass;
                // decrease counters
                $class::updateAllCounters(['count' => -1], ['in', $class::primaryKey(), $this->_tagsForDelete]);
                // delete links
                $this->owner->getDb()
                    ->createCommand()
                    ->delete($relation->via->from[0], [key($relation->via->link) => $this->owner->getPrimaryKey()])
                    ->execute();
            }
            $this->_tagsForDelete = [];
        }
    }
public function afterDelete()
    {
        // after complete owner delete delete tags links
        if (!empty($this->_tagsForDelete)) {
            $relation = $this->owner->getRelation('tagsList', false);
            if ($relation instanceof ActiveQuery) {
                /** @var ActiveRecord $class */
                $class = $relation->modelClass;
                // decrease counters
                $class::updateAllCounters(['count' => -1], ['in', $class::primaryKey(), $this->_tagsForDelete]);
                // delete links
                $this->owner->getDb()
                    ->createCommand()
                    ->delete($relation->via->from[0], [key($relation->via->link) => $this->owner->getPrimaryKey()])
                    ->execute();
            }
            $this->_tagsForDelete = [];
        }
    }
public function afterDelete ( ) { // after complete owner delete delete tags links if ( ! empty ( $ this -> _tagsForDelete ) ) { $ relation = $ this -> owner -> getRelation ( 'tagsList' , false ) ; if ( $ relation instanceof ActiveQuery ) { /** @var ActiveRecord $class */ $ class = $ relation -> modelClass ; // decrease counters $ class :: updateAllCounters ( [ 'count' => - 1 ] , [ 'in' , $ class :: primaryKey ( ) , $ this -> _tagsForDelete ] ) ; // delete links $ this -> owner -> getDb ( ) -> createCommand ( ) -> delete ( $ relation -> via -> from [ 0 ] , [ key ( $ relation -> via -> link ) => $ this -> owner -> getPrimaryKey ( ) ] ) -> execute ( ) ; } $ this -> _tagsForDelete = [ ] ; } }
After delete event
After delete event