pull/81/head
d_yanis 1 year ago
parent 8a3c4379ab
commit a9948ba767

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

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

@ -81,5 +81,8 @@ class TeamGateway {
)[0]['id'] ?? null;
}
public function getAll(int $user) : array {
return $this->con->fetch("SELECT * FROM Team", []);
}
}

@ -79,4 +79,10 @@ class TeamModel {
return $teamId;
}
public function getAll(int $user) {
$res = $this->teams->getAll($user);
var_dump($res);
return $res;
}
}

Loading…
Cancel
Save