public function actionDeleteonemoment() { $id = $_POST['moment']; $moment = new Moments(); // $momenttop=new MomentTop(); // $thetop=MomentTop::find(['moment_id'=>$id]); // $thetop->delete(); if ($thetop = MomentTop::find()->where(['moment_id' => $id])->one()) { $thetop->delete(); } $moment->deleteOneMoment($id); echo '{"success":true}'; }