Delete team and related times
This commit is contained in:
parent
d47a34d530
commit
326b09893a
@ -85,4 +85,10 @@ class TimeMapper
|
|||||||
$sth = $this->dbh->prepare('DELETE FROM tidtabell WHERE TidID = ?');
|
$sth = $this->dbh->prepare('DELETE FROM tidtabell WHERE TidID = ?');
|
||||||
$sth->execute([$id]);
|
$sth->execute([$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteByTeamId(int $team_id): void
|
||||||
|
{
|
||||||
|
$sth = $this->dbh->prepare('DELETE FROM tidtabell WHERE LagID = ?');
|
||||||
|
$sth->execute([$team_id]);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,12 +1,17 @@
|
|||||||
<?php $app = require '../../../../app/inc.php';
|
<?php $app = require '../../../../app/inc.php';
|
||||||
|
/**
|
||||||
|
* Deletes both team and related times
|
||||||
|
*/
|
||||||
|
|
||||||
use App\Teamtable\Team;
|
use App\Teamtable\Team;
|
||||||
use App\Teamtable\TeamMapper;
|
use App\Teamtable\TeamMapper;
|
||||||
|
use App\Timetable\TimeMapper;
|
||||||
|
|
||||||
$item = filter_input(INPUT_GET, 'item', FILTER_VALIDATE_INT);
|
$item = filter_input(INPUT_GET, 'item', FILTER_VALIDATE_INT);
|
||||||
$confirm = filter_input(INPUT_GET, 'confirm', FILTER_VALIDATE_BOOLEAN);
|
$confirm = filter_input(INPUT_GET, 'confirm', FILTER_VALIDATE_BOOLEAN);
|
||||||
|
|
||||||
$team_mapper = new TeamMapper($app->database->conn);
|
$team_mapper = new TeamMapper($app->database->conn);
|
||||||
|
$time_mapper = new TimeMapper($app->database->conn);
|
||||||
|
|
||||||
// item is NULL if not set
|
// item is NULL if not set
|
||||||
if ($item === NULL)
|
if ($item === NULL)
|
||||||
@ -32,7 +37,8 @@ if (!$confirm)
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
// all is good, lets delete the team
|
// all is good, lets delete the team and related times
|
||||||
|
$time_mapper->deleteByTeamId($team->id);
|
||||||
$team_mapper->delete($team->id);
|
$team_mapper->delete($team->id);
|
||||||
$app->session->flash("Slettet lag: {$team->name}", "success");
|
$app->session->flash("Slettet lag: {$team->name}", "success");
|
||||||
$app->redirect('index.php');
|
$app->redirect('index.php');
|
Reference in New Issue
Block a user