<?php
declare(strict_types=1);
namespace App\Controller\Dashboard\Coach;
use App\Entity\Experience;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route('/coach')]
class CoachAccountController extends AbstractController
{
#[Route('/mon-compte', name: 'coach_account', methods: ['GET'])]
public function overviewCoach(UserRepository $userRepository): Response
{
$coach = $userRepository->find(1);
//$coach = $this->getUser();
return $this->render('coach/account/overview.html.twig',[
'coach' => $coach,
]);
}
#[Route('/mon-profile', name: 'coach_profile', methods: ['GET'])]
public function profileCoach(): Response{
$coach = $this->getUser();
return $this->render('coach/account/profile.html.twig', [
'coach' => $coach,
]);
}
#[Route('/mes-reservations', name: 'coach_reservation', methods: ['GET'])]
public function reservationCoach(): Response
{
return $this->render('admin/booking/coach/mesReservation.html.twig');
}
#[Route('/coach-faq', name: 'coach_faq', methods: ['GET'])]
public function questionnaireCoach(): Response{
return $this->render('coach/questionnaireCoach.html.twig');
}
#[Route('/mon-securite', name: 'coach_securite', methods: ['GET'])]
public function securiteCoach(): Response{
return $this->render('coach/account/securite.html.twig');
}
#[Route('/mes-experiences', name: 'coach_experiences_list', methods: ['GET'])]
public function listCoachExperiences(ManagerRegistry $doctrine): Response
{
$em = $doctrine->getManager();
$user = $this->getUser();
$coachExperiences = $em->getRepository(Experience::class)
->createQueryBuilder('e')
->andWhere('e.coach = :coach')
->setParameter('coach', $user)
->orderBy('e.id', 'DESC')
->getQuery()
->getResult();
return $this->render('coach/experience/mesExperiences.html.twig', [
'experiences' => $coachExperiences,
]);
}
#[Route('/mes-clients', name: 'coach_customers', methods: ['GET'])]
public function coachCustomers(): Response
{
//$coach = $this->getUser();
//$qb = $em->createQueryBuilder()
// ->select('c')
// ->from(Booking::class, 'b')
// ->join('b.experience', 'e')
// ->andWhere('e.coach = :coach')
// ->join('b.user', 'c')
//->andWhere('c != :coach')
//->setParameter('coach', $coach)
//->groupBy('c.id')
// ->orderBy('c.lastname', 'ASC');
//$clients = $qb->getQuery()->getResult();
return $this->render('coach/customer/myCustomers.html.twig');
}
}