src/Controller/DashboardController.php line 20
<?phpnamespace App\Controller;use App\Entity\Charge;use App\Entity\Payment;use App\Repository\EntrepriseRepository;use App\Repository\SubscriptionRepository;use App\Repository\UserEntrepriseRepository;use App\Repository\UserRepository;use Doctrine\ORM\EntityManagerInterface;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\Uid\Uuid;class DashboardController extends AbstractController{#[Route('/admin', name: 'app_dashboard')]public function index(SubscriptionRepository $subscriptionRepository,EntrepriseRepository $entrepriseRepository): Response {// $users = $userRepository->findAll();// foreach ($users as $user){// $existing = $userEntrepriseRepository->findOneBy([// 'user' => $user,// 'entreprise' => $user->getEntreprise(),// ]);// if (!$existing) {// if($user->getEntreprise()) {// $link = new UserEntreprise();// $link->setUser($user);// $link->setEntreprise($user->getEntreprise());// $link->setRole('STAFF');// $link->setStatus(true);// $em->persist($link);// $em->flush();// }// }// }// $charge = $em->getRepository(Charge::class)->find(1812);//// foreach ($charges as $charge){// if (!$charge->getPayment()){//// $payment = new Payment();// $payment->setCode(Uuid::v4());// $payment->setMarchand($charge->getMarchand());// $payment->setLocation($charge->getLocation());// $payment->setReference($charge->getMarchand()->getPseudo().'-'.uniqid());// $payment->setMonth($charge->getMonth());// $payment->setYear($charge->getYear());// $payment->setPaid(false);// $payment->setTotalAmount((float)$charge->getAmount());// $payment->setSingleAmount((float)$charge->getAmount());//// $charge->setPayment($payment);//// $em->persist($payment);// $em->flush();// }// }$entreprises = $entrepriseRepository->findBy(['admin' => $this->getUser()], ['id' => 'DESC']);$activeEntreprises = count($entrepriseRepository->findBy(['admin' => $this->getUser(), 'status' => true]));$allEntrepriseCount = count($entreprises);$entreprise = $entrepriseRepository->findOneBy(['admin' => $this->getUser()]);$subscriptionCount = count($subscriptionRepository->findBy(['entreprise' => $entreprise, 'paid' => true]));return $this->render('dashboard/index.html.twig', ['entreprises' => $entreprises,'activeEntreprise' => $activeEntreprises,'allEntrepriseCount' => $allEntrepriseCount,'subscriptionCount' => $subscriptionCount]);}}