public function beforeDelete() { $pks = []; foreach ($this->owner->tags as $tag) { $pks[] = $tag->primaryKey; } if (count($pks)) { Tag::updateAllCounters(['frequency' => -1], ['in', 'tag_id', $pks]); } Tag::deleteAll(['frequency' => 0]); TagIndex::deleteAll(['entity' => $this->getEntityClass(), 'entity_id' => $this->getEntityId()]); }
/** * * @param unknown $id */ public function actionRead($id) { $dataProvider = new ActiveDataProvider(['query' => TagIndex::find()->where(["tag_id" => $id]), 'pagination' => ['pageSize' => 15]]); return $this->render('view', ['tagIndexs' => $dataProvider->getModels(), "pagination" => $dataProvider->getPagination()]); }