public function actionDelete($id) { $request = \Yii::$app->request; $ajax = $request->isAjax; if (!\app\helpers\Csrf::check()) { return $ajax ? json_encode(['success' => false]) : $this->goHome(); } Model::directDelete($id); return $ajax ? json_encode(['success' => true]) : $this->redirect(static::URL_TO_INDEX); }
public function actionDelete($id) { $request = \Yii::$app->request; $ajax = $request->isAjax; if (!\app\helpers\Csrf::check()) { return $ajax ? json_encode(['success' => false]) : $this->goHome(); } if (!is_array($id)) { $id = explode(',', $id); } $id = array_diff($id, [\Yii::$app->user->id]); if ($id) { Model::directDelete($id); } return $ajax ? json_encode(['success' => true]) : $this->redirect(static::URL_TO_INDEX); }