diff --git a/app/model/Teamtable.php b/app/model/Teamtable.php deleted file mode 100644 index 308ef54..0000000 --- a/app/model/Teamtable.php +++ /dev/null @@ -1,46 +0,0 @@ -dbh = $database->conn; - $this->teamMapper = new TeamMapper($this->dbh); - } - - public function getAll(): array - { - return $this->teamMapper->getAll(); - } - - public function get(int $id): ?Team - { - return $this->teamMapper->get($id); - } - - public function create(Team $team): Team - { - return $this->teamMapper->create($team); - } - - public function delete(int $id): void - { - $this->teamMapper->delete($id); - } - - public function update(Team $team): Team - { - return $this->teamMapper->update($team); - } -} \ No newline at end of file diff --git a/public/race/configure/teams/delete.php b/public/race/configure/teams/delete.php index 67230d0..5ba9d4a 100644 --- a/public/race/configure/teams/delete.php +++ b/public/race/configure/teams/delete.php @@ -1,11 +1,12 @@ model('Teamtable'); +$teamMapper = new TeamMapper($app->database->conn); // item is NULL if not set if ($item === NULL) @@ -14,7 +15,7 @@ if ($item === NULL) $app->redirect('index.php'); } -$team = $model->get($item); +$team = $teamMapper->get($item); if (!$team) { // team does not exist @@ -32,6 +33,6 @@ if (!$confirm) } // all is good, lets delete the team -$model->delete($team->id); +$teamMapper->delete($team->id); $app->session->flash("Slettet lag: {$team->name}", "success"); $app->redirect('index.php'); \ No newline at end of file diff --git a/public/race/configure/teams/index.php b/public/race/configure/teams/index.php index 1ff4c5c..e55cc14 100644 --- a/public/race/configure/teams/index.php +++ b/public/race/configure/teams/index.php @@ -1,8 +1,10 @@ model('Teamtable'); +use App\Teamtable\TeamMapper; -$teams = $model->getAll(); +$teamMapper = new TeamMapper($app->database->conn); + +$teams = $teamMapper->getAll(); $app->view('template/header', ['title' => 'Endre lagtabell']); $app->view('pages/race/configure/teams/index', ["teams" => $teams]); diff --git a/public/race/configure/teams/update.php b/public/race/configure/teams/update.php index 3c19748..c598f6b 100644 --- a/public/race/configure/teams/update.php +++ b/public/race/configure/teams/update.php @@ -4,15 +4,16 @@ */ use App\Teamtable\Team; +use App\Teamtable\TeamMapper; $item = filter_input(INPUT_GET, 'item', FILTER_VALIDATE_INT); -$model = $app->model('Teamtable'); +$teamMapper = new TeamMapper($app->database->conn); $team; if ($item !== NULL) { - $team = $model->get($item); + $team = $teamMapper->get($item); if (!$team) { // team does not exist @@ -47,12 +48,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') { // team exists, lets update it $team->id = $item; - $model->update($team); + $teamMapper->update($team); $app->session->flash('Oppdaterte lag', 'success'); $app->redirect('index.php'); } // no team was specified, lets create one - $model->create($team); + $teamMapper->create($team); $app->session->flash('Opprettet nytt lag', 'success'); $app->redirect('index.php'); }