diff --git a/front/style/home.css b/front/style/home.css index c6989e9..ed496dc 100644 --- a/front/style/home.css +++ b/front/style/home.css @@ -21,12 +21,12 @@ #body { display: flex; flex-direction: row; - border : solid 10px yellow; + border : solid 10px violet; margin:0px } #personal-space { - background-color: red; + background-color: orange; } #sideMenu { diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php index 4447df6..bc4e91d 100644 --- a/src/App/Controller/UserController.php +++ b/src/App/Controller/UserController.php @@ -23,8 +23,8 @@ class UserController { * @return ViewHttpResponse the home page view */ public function home(SessionHandle $session): ViewHttpResponse { - $lastTactic = $this->tactics->getLast(5); - var_dump($session->getAccount()); + $limitNbTactics = 5; + $lastTactic = $this->tactics->getLast($limitNbTactics, $session->getAccount()->getId()); return ViewHttpResponse::react("views/Home.tsx", [ "lastTactics" => $lastTactic ]); diff --git a/src/Core/Gateway/TacticInfoGateway.php b/src/Core/Gateway/TacticInfoGateway.php index 1f507cf..781c525 100644 --- a/src/Core/Gateway/TacticInfoGateway.php +++ b/src/Core/Gateway/TacticInfoGateway.php @@ -45,10 +45,16 @@ class TacticInfoGateway { * @param integer $nb * @return array> */ - public function getLast(int $nb): ?array { + public function getLast(int $nb, int $ownerId): ?array { $res = $this->con->fetch( - "SELECT * FROM Tactic ORDER BY creation_date DESC LIMIT :nb ", - [":nb" => [$nb, PDO::PARAM_INT]] + "SELECT * + FROM Tactic + WHERE owner = :ownerId + ORDER BY creation_date + DESC LIMIT :nb", + [ + ":ownerId" => [$ownerId, PDO::PARAM_INT],":nb" => [$nb, PDO::PARAM_INT] + ] ); if (count($res) == 0) { return []; diff --git a/src/Core/Model/TacticModel.php b/src/Core/Model/TacticModel.php index 5435922..fd8764f 100644 --- a/src/Core/Model/TacticModel.php +++ b/src/Core/Model/TacticModel.php @@ -3,6 +3,7 @@ namespace IQBall\Core\Model; use IQBall\Core\Data\CourtType; +use IQBall\App\Session\SessionHandle; use IQBall\Core\Data\TacticInfo; use IQBall\Core\Gateway\TacticInfoGateway; use IQBall\Core\Validation\ValidationFail; @@ -61,8 +62,8 @@ class TacticModel { /** * Return the nb last tactics */ - public function getLast(int $nb): ?array { - return $this->tactics->getLast($nb); + public function getLast(int $nb, int $ownerId): ?array { + return $this->tactics->getLast($nb, $ownerId); } /**