Skip to content

Instantly share code, notes, and snippets.

@hugofabricio
Created October 3, 2013 17:07
Show Gist options
  • Select an option

  • Save hugofabricio/6813288 to your computer and use it in GitHub Desktop.

Select an option

Save hugofabricio/6813288 to your computer and use it in GitHub Desktop.
/**
* Painel Delete
*/
public function painel_delete($id = null)
{
// Prova
$this->Task->id = $id;
// Se o registro não for encontrado
if (!$this->Task->exists()):
throw new NotFoundException('Prova não encontrada.');
endif;
// Se existir efetua a ação de exclusão
if ($this->Task->delete()):
$this->Session->setFlash('Excluído com sucesso.', SUCCESS);
$this->redirect(array('action' => 'index', 'painel' => true));
endif;
// Mensagem de erro
$this->Session->setFlash('Falha ao excluir.', WARNING);
// Redireciona
$this->redirect(array('action' => 'index', 'painel' => true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment