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