src/Controller/SupportController.php line 23

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\SupportTickets;
  4. use Doctrine\Persistence\ManagerRegistry as Registry;
  5. use Symfony\Bridge\Doctrine\ManagerRegistry;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class SupportController extends AbstractController
  11. {
  12.     private ManagerRegistry $doctrine;
  13.     public function __construct(Registry $doctrine)
  14.     {
  15.         $this->doctrine $doctrine;
  16.     }
  17.     #[Route('/support'name'app_support')]
  18.     public function index(): Response
  19.     {
  20.         $data = [
  21.             'pageTitle' => 'Web Hosting Support | Little Welsh Hosting Company',
  22.             'pageDescription' => ''
  23.         ];
  24.         return $this->render('support/index.html.twig', [
  25.             'data' => $data,
  26.         ]);
  27.     }
  28.     // ADMIN SECTION
  29.     #[Route('/admin/support'name'app_admin_support')]
  30.     public function list(): Response
  31.     {
  32.         $tickets $this->doctrine->getRepository(SupportTickets::class)->findAll();
  33.         return $this->render('admin/support/list.html.twig', [
  34.             'tickets' => $tickets
  35.         ]);
  36.     }
  37.     #[Route('/admin/support/update/{uuid}'name'app_admin_support_update')]
  38.     public function edit(Request $requeststring $uuid): Response
  39.     {
  40.         $ticket $this->doctrine->getRepository(SupportTickets::class)->findOneBy([
  41.             'uuid' => $uuid
  42.         ]);
  43.         $replies $this->doctrine->getRepository(SupportTicketReplies::class)->findBy([
  44.             'tickets' => $ticket
  45.         ]);
  46.         $now = new \DateTime("now");
  47.         $em $this->doctrine->getManager();
  48.         $ticket->setUserRead($now);
  49.         $em->flush();
  50.         return $this->renderForm('admin/support/edit.html.twig', [
  51.             'ticket' => $ticket,
  52.             'replies' => $replies,
  53.             'repliesForm' => $form,
  54.         ]);
  55.     }
  56. }