public function deleteItem($condition = []) { $data = News::findOne($condition); $data->isDeleted = true; $data->save(); }
public function actionDelete($id) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $accountId = $this->getAccountId(); if (empty($accountId)) { return ['data' => 401, 'detail ' => 'No info found with this account Id.', 'event' => [], 'success' => 0]; } $news = new News(); $news->deleteItem(['accountId' => $accountId, '_id' => $id]); $results = ['code' => 200, 'success' => 1]; unset($news); unset($item); return $results; }