Fix the owner issue

Rebasing
pull/81/head
DahmaneYanis 1 year ago committed by d_yanis
parent 90b18008eb
commit d816b3b0aa

@ -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 {

@ -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
]);

@ -45,10 +45,16 @@ class TacticInfoGateway {
* @param integer $nb
* @return array<array<string,mixed>>
*/
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 [];

@ -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);
}
/**

Loading…
Cancel
Save