public function deleteAction($id) { $auth = Session::get('auth'); if ($auth) { $id = $this->filter->sanitize($id, array('int')); $player = Players::findFirst('id=' . $id); if (!$player) { Session::setFlash('error', 'Player not found', 'alert alert-error'); $this->response->redirect('players/'); } if (!$player->delete()) { foreach ($player->getMessages() as $message) { Session::setFlash('error', (string) $message, 'alert alert-error'); } $this->response->redirect('players/'); } else { Session::setFlash('success', 'Episode deleted successfully', 'alert alert-success'); $this->response->redirect('players/'); } } }