diff --git a/public/index.php b/public/index.php index 8b375d0..b3205ab 100644 --- a/public/index.php +++ b/public/index.php @@ -38,7 +38,7 @@ function getConnection(): Connection { } function getUserController(): UserController { - return new UserController(new TacticModel(new TacticInfoGateway(getConnection()))); + return new UserController(new TacticModel(new TacticInfoGateway(getConnection())), new TeamModel( new TeamGateway(getConnection()), new MemberGateway(getConnection()), new AccountGateway(getConnection()))); } function getVisualizerController(): VisualizerController { diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php index 0af4214..f2444a5 100644 --- a/src/App/Controller/UserController.php +++ b/src/App/Controller/UserController.php @@ -7,15 +7,19 @@ use IQBall\App\Session\SessionHandle; use IQBall\App\ViewHttpResponse; use IQBall\Core\Http\HttpResponse; use IQBall\Core\Model\TacticModel; +use IQBall\Core\Model\TeamModel; class UserController { private TacticModel $tactics; + private ?TeamModel $teams; + /** * @param TacticModel $tactics */ - public function __construct(TacticModel $tactics) { + public function __construct(TacticModel $tactics, ?TeamModel $teams = NULL) { $this->tactics = $tactics; + $this->teams = $teams; } /** @@ -26,6 +30,12 @@ class UserController { $limitNbTactics = 5; $lastTactics = $this->tactics->getLast($limitNbTactics, $session->getAccount()->getId()); $allTactics = $this->tactics->getAll($session->getAccount()->getId()); + + //TODO + if ($this->teams != NULL) { + $teams = $this->teams->getAll($session->getAccount()->getId()); + } + return ViewHttpResponse::react("views/Home.tsx", [ "lastTactics" => $lastTactics, "allTactics" => $allTactics diff --git a/src/Core/Gateway/TeamGateway.php b/src/Core/Gateway/TeamGateway.php index d775eda..cfadd89 100644 --- a/src/Core/Gateway/TeamGateway.php +++ b/src/Core/Gateway/TeamGateway.php @@ -81,5 +81,8 @@ class TeamGateway { )[0]['id'] ?? null; } + public function getAll(int $user) : array { + return $this->con->fetch("SELECT * FROM Team", []); + } } diff --git a/src/Core/Model/TeamModel.php b/src/Core/Model/TeamModel.php index f6af837..c2df190 100644 --- a/src/Core/Model/TeamModel.php +++ b/src/Core/Model/TeamModel.php @@ -79,4 +79,10 @@ class TeamModel { return $teamId; } + public function getAll(int $user) { + $res = $this->teams->getAll($user); + var_dump($res); + return $res; + } + }