Affichage ami

merged_PLE
Paul LEVRAULT 1 year ago
parent 6786eea1c4
commit bc0b4ee2d6

@ -12,10 +12,10 @@ $dotenv->safeLoad();
// const DB_PASSWORD = $_ENV['DB_PASSWORD'] ?? 'achanger';
define("APP_ENV", 'development');
const DB_SERVER = 'pgsql';
const DB_SERVER = 'mysql';
const DB_HOST = 'localhost';
const DB_DATABASE = 'sae_3';
const DB_USER = 'Perederii';
const DB_DATABASE = 'new';
const DB_USER = 'root';
const DB_PASSWORD = '';
//const APP_ENV = 'console';

@ -421,20 +421,25 @@ class AthleteController extends BaseController
try {
$athleteGateway = new AthleteGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$map=new AthleteMapper();
$friendEntity = $athleteGateway->getListIdFriends(1/*$currentUser->getId()*/);
$friendList = [];
$listUserEntity = [];
foreach($friendEntity as $users) {
if ($users['idathlete1']==1/*$currentUser->getId()*/){
$user=(int)$users['idathlete2'];
$friendEntity = $athleteGateway->getListIdFriends(3/*$currentUser->getId()*/);
foreach($friendEntity as $friendship){
if($friendship['idAthlete1']==3/*$currentUser->getId()*/){
$listFriend[]=$friendship['idAthlete2'];
} else {
$user=(int)$users['idathlete1'];
$listFriend[]=$friendship['idAthlete1'];
}
$listUserEntity[] = $map->athleteSqlToEntity($athleteGateway->getAthleteById(1));
}
foreach($listFriend as $friend){
$friends[]=$athleteGateway->getById($friend);
}
foreach($friends as $friend){
$friendlist[]=$friend[0];
}
$listUserEntity = $map->athleteSqlToEntity($friendlist);
foreach ($listUserEntity as $user) {
$friendList[] = ['nom' => $user[0]->getNom(), 'prenom' => $user[0]->getPrenom(), 'img' => 'test', 'username' => 'test'];
$friendList[] = ['nom' => $user->getNom(), 'prenom' => $user->getPrenom(), 'img' => 'test', 'username' => $user->getUsername()];
}
$response = $this->render('./page/friend.html.twig',[

@ -22,7 +22,6 @@ class AthleteGateway {
{
$query = "SELECT * FROM Athlete WHERE idAthlete = :id AND isCoach=FALSE";
$params = [':id' => $userId];
// log::dd($params);
$res = $this->connection->executeWithErrorHandling($query, $params);
return $res;
}
@ -90,10 +89,10 @@ class AthleteGateway {
public function getListActivity(int $idAthlete): array
{
$query = "SELECT count(ac.idActivite) AS nbActivite, EXTRACT(MONTH FROM ac.date) AS mois
FROM Athlete at, Activite ac
WHERE at.idAthlete = :idAthlete
FROM Athlete ath, Activite ac
WHERE ath.idAthlete = :idAthlete
AND ac.date > CURRENT_DATE - INTERVAL '1 YEAR'
AND ac.athleteId = at.idAthlete
AND ac.athleteId = ath.idAthlete
GROUP BY mois";
$params = [
@ -158,6 +157,14 @@ class AthleteGateway {
return $this->connection->executeWithErrorHandling($query, $params);
}
public function getById(int $userId): array
{
$query = "SELECT * FROM Athlete WHERE idAthlete = :id";
$params = [':id' => $userId];
$res = $this->connection->executeWithErrorHandling($query, $params);
return $res;
}
}

@ -57,7 +57,7 @@ class AthleteMapper {
if (isset($athleteData['isCoach'])) {
$athlete->setIsCoach($athleteData['isCoach']);
}
$athleteEntities[] = $athlete;
}

Loading…
Cancel
Save