init project
This commit is contained in:
62
src/Controller/BackendAdmin/ActiverController.php
Normal file
62
src/Controller/BackendAdmin/ActiverController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user