コード例 #1
0
 /**
  * Deletes an existing Blog model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     foreach (BlogTag::find()->where(['blog_id' => $model->id])->with('tag')->all() as $removedItem) {
         $removedItem->tag->frequency--;
         $removedItem->tag->save();
         $removedItem->delete();
     }
     $model->delete();
     return $this->redirect(['index']);
 }
コード例 #2
0
ファイル: Blog.php プロジェクト: besnovatyj/yii2-blog-module
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBlogTag()
 {
     return $this->hasOne(BlogTag::className(), ['blog_id' => 'id']);
 }