如何从yii2控制器中的两个表中删除数据

How to delete the dat from two tables in yii2 controller

我有日历和通知模型。我正在从日历控制器中删除两个模型的数据。当我尝试使用给定代码删除时,没有任何反应,两个记录都按原样提醒。我被重定向到通知控制器..如何修复此重定向.. ...\index.php?r=notifications/delete&id=1

我试过了 die();重定向前的语句和两条记录都已成功删除..

 public function actionDelete($id)
    {
       // die("deleting");
        if(Calendar::find()->where(['id' =>$id])->one()->delete())
        {
            echo "Calendar Deleted... ...<br>";
            if( Notifications::find()->where(['calndar_id' =>$id])->one()->delete())
            {
                echo "Notification Deleted ....<br>";
                $this->redirect(array('index1','message'=>"Calendar & Respective Notification Deleted Successfully"));
            }
            else
            {
                $this->redirect(array('index1','message'=>"Calendar Deleted Successfully"));

            }

        }
    }

预期结果是 1)两条记录都应该被删除并将重定向到 ..\index.php?r=calendar\index

每个 redirect() 函数必须与 return

一起使用
public function actionDelete($id)
{
   // die("deleting");
    if(Calendar::find()->where(['id' =>$id])->one()->delete())
    {
        echo "Calendar Deleted... ...<br>";
        if( Notifications::find()->where(['calndar_id' =>$id])->one()->delete())
        {
            echo "Notification Deleted ....<br>";
            return $this->redirect(array('index1','message'=>"Calendar & Respective Notification Deleted Successfully"));
        }
        else
        {
            return $this->redirect(array('index1','message'=>"Calendar Deleted Successfully"));

        }

    }
}