/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $model = $this->loadModel($id); $model->excluida = 1; $conditions = 'tamanho_tipo_massa_id = ' . $model->id; $pizza = Pizza::model()->find($conditions); if (empty($pizza)) { $model->delete(); } else { $model->save(); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index')); } }