WIP did a few little changes
continuous-integration/drone/push Build is passing Details

pull/16/head
Maël DAIM 1 year ago
parent 30611b9b21
commit 1acede4169

@ -74,7 +74,8 @@ class TeamController /* verif si les camp sont assignés, sinon erreur 400*/
}
public function displayTeam(int $id): HttpResponse{
$results = $this->model->displayTeam($id);
$result = $this->model->displayTeam($id);
return ViewHttpResponse::twig('display_team.html.twig',['team' => $result]);
}
}

@ -11,6 +11,7 @@ class Member {
*/
private int $userId;
private string $email;
/**
* @var MemberRole the member's role
*/
@ -18,13 +19,16 @@ class Member {
/**
* @param int $userId
* @param string $email
* @param MemberRole $role
*/
public function __construct(int $userId, MemberRole $role) {
public function __construct(int $userId, string $email, MemberRole $role) {
$this->userId = $userId;
$this->email = $email;
$this->role = $role;
}
/**
* @return int
*/
@ -39,4 +43,11 @@ class Member {
return $this->role;
}
/**
* @return string
*/
public function getEmail(): string {
return $this->email;
}
}

@ -44,7 +44,7 @@ class TeamGateway {
public function getMembersById($id):array{
return $this->con->fetch(
"SELECT p.role,m.email FROM Member m,Team t,Participate p WHERE t.id = :id AND p.idTeam = t.id AND p.idMember = m.id",
"SELECT p.role,m.email,m.id FROM Member m,Team t,Participate p WHERE t.id = :id AND p.idTeam = t.id AND p.idMember = m.id",
[
":id" => [$id, PDO::PARAM_INT]
]

@ -1,8 +1,11 @@
<?php
namespace App\Model;
use App\Data\Color;
use App\Gateway\TeamGateway;
use App\Data\Team;
use App\Data\Member;
use App\Data\MemberRole;
/**
*
@ -14,27 +17,37 @@ class TeamModel /* throw des exceptions(ex validation des champs, filtre etc) po
/**
* @param TeamGateway $gateway
*/
public function __construct(TeamGateway $gateway)
{
public function __construct(TeamGateway $gateway) {
$this->gateway = $gateway;
}
public function createTeam(string $name,string $picture,int $mainColor, int $secondColor) {
$this->gateway->insert($name,$picture,$mainColor,$secondColor);
public function createTeam(string $name, string $picture, int $mainColor, int $secondColor) {
$this->gateway->insert($name, $picture, $mainColor, $secondColor);
}
public function listByName(string $name):array {
$teams=[];
public function listByName(string $name): array {
$teams = [];
$results = $this->gateway->listByName($name);
foreach ($results as $row){
$teams[] = new Team($row['id'],$row['name'],$row['picture'],$row['mainColor'],$row['secondColor']);
foreach ($results as $row) {
$teams[] = new Team($row['id'], $row['name'], $row['picture'], $row['mainColor'], $row['secondColor']);
}
return $teams;
}
public function displayTeam(int $id): array{
$resultTeam = $this->gateway->getTeamById($id);
public function displayTeam(int $id): Team {
$members = [];
$result = $this->gateway->getTeamById($id);
$resultMembers = $this->gateway->getMembersById($id);
foreach ($resultMembers as $row) {
if ($row['role'] == 'C') {
$role = 1;
} else {
$role = 2;
}
$members[] = new Member($row['id'], $row['email'], $role);
}
$team = new Team($result['id'], $result['name'], $result['picture'], $result['mainColor'], $result['secondColor'], $members);
return $team;
}
}

@ -6,30 +6,12 @@
</head>
<body>
<h1>Hello world</h1>
<h1>{{ team.name }}</h1>
{% if teams is empty %}
<p>Aucune équipe n'a été trouvée</p>
<div class="container">
<h2>Chercher une équipe</h2>
<form action="/team/list" method="post">
<div class="form-group">
<label for="name">Nom de l'équipe :</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<input type="submit" value="Confirmer">
</div>
</form>
</div>
{% else %}
{% for t in teams %}
<div onclick="window.location.href = '/team/{{ t.id }}'">
<p>Nom de l'équipe: {{ t.name }}</p>
<p>picture : {{ t.picture }}</p>
</div>
{% endfor %}
{% endif %}
{% for m in team.members %}
<p> m.email </p>
{% endfor %}
</body>
</html>

@ -6,8 +6,6 @@
</head>
<body>
<h1>Hello world</h1>
{% if teams is empty %}
<p>Aucune équipe n'a été trouvée</p>
<div class="container">

Loading…
Cancel
Save