Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
Arquivo: Users.php Projeto: semnt/tp01
 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);
 }