database->conn); // item is NULL if not set if ($item === NULL) { $app->session->flash('Kunne ikke slette lag: Mangler parameter.', 'danger'); $app->redirect('index.php'); } $team = $team_mapper->get($item); if (!$team) { // team does not exist $app->session->flash('Kunne ikke slette lag: Lag eksisterer ikke', 'danger'); $app->redirect('index.php'); } // show confirmation page if (!$confirm) { $app->view('template/header', ['title' => 'Bekreft sletting']); $app->view('pages/race/configure/teams/delete', ['team' => $team]); $app->view('template/footer'); die(); } // all is good, lets delete the team $team_mapper->delete($team->id); $app->session->flash("Slettet lag: {$team->name}", "success"); $app->redirect('index.php');