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/app/model/Teamtable.php
2022-03-10 16:52:59 +01:00

58 lines
1.1 KiB
PHP

<?php
use App\Core\Database as Database;
use App\Teamtable\Team as Team;
use App\Teamtable\TeamMapper as TeamMapper;
/**
* Does stuffs with the teamtable
*/
class Teamtable
{
public PDO $dbh;
/**
* We use a data mapper pattern
*/
public TeamMapper $teamMapper;
public function __construct(Database $database)
{
$this->dbh = $database->conn;
$this->teamMapper = new TeamMapper($this->dbh);
}
/**
* Fetch entire team table
*/
public function getAll(): array
{
return $this->teamMapper->getAll();
}
/**
* Find team with supplied id
*/
public function get(int $id): ?Team
{
return $this->teamMapper->get($id);
}
/**
* Inserts team into database
*/
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);
}
}