This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/public/teamtable/edit/delete.php
2022-03-07 07:13:17 +01:00

37 lines
975 B
PHP

<?php $app = require '../../../app/inc.php';
use App\Teamtable\Team;
$item = filter_input(INPUT_GET, 'item', FILTER_VALIDATE_INT);
$confirm = filter_input(INPUT_GET, 'confirm', FILTER_VALIDATE_BOOL);
$model = $app->model('Teamtable');
// item is NULL if not set
if ($item === NULL)
{
$app->session->flash('Kunne ikke slette lag: Mangler parameter.', 'danger');
$app->redirect('index.php');
}
$team = $model->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/teamtable/edit/delete', ['team' => $team]);
$app->view('template/footer');
die();
}
// all is good, lets delete the team
$model->delete($team->id);
$app->session->flash("Slettet lag: {$team->name}", "success");
$app->redirect('index.php');