Files
PowerPME_Web/src/Controller/BackendAdmin/ActiverController.php
2025-10-27 13:12:25 +01:00

63 lines
1.8 KiB
PHP

<?php
namespace App\Controller\BackendAdmin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Routing\Attribute\Route;
use App\Entity\SoftwareActivation;
use App\Repository\SoftwareActivationRepository;
#[Route('/admin/activer')]
final class ActiverController extends AbstractController
{
/**
* @param EntityManagerInterface $em
* @param SoftwareActivationRepository $softwareActivationRepository
*/
public function __construct(
private EntityManagerInterface $em,
private SoftwareActivationRepository $softwareActivationRepository
)
{
$this->softwareActivationRepository = $softwareActivationRepository;
$this->em = $em;
}
#[Route('/index', name: 'admin_activer_index')]
public function index(): Response
{
return $this->render('backend/admin/activer/index.html.twig', [
'softwareActivations'=>$this->softwareActivationRepository->findBy(['user'=>null], ["id"=>'DESC'])
]);
}
#[Route('/activation/{id}', name: 'admin_activer_activation')]
public function activation(SoftwareActivation $softwareActivation): Response
{
$softwareActivation->setStatu(1);
$softwareActivation->setDateAdd(new \DateTime());
$this->em->persist($softwareActivation);
$this->em->flush();
return $this->redirectToRoute('admin_activer_index');
}
#[Route('/delete/{id}', name: 'admin_activer_delete')]
public function delete(SoftwareActivation $softwareActivation): Response
{
$this->em->remove($softwareActivation);
$this->em->flush();
return $this->redirectToRoute('admin_activer_index');
}
}