src/Controller/SupportController.php line 23
<?php
namespace App\Controller;
use App\Entity\SupportTickets;
use Doctrine\Persistence\ManagerRegistry as Registry;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class SupportController extends AbstractController
{
private ManagerRegistry $doctrine;
public function __construct(Registry $doctrine)
{
$this->doctrine = $doctrine;
}
#[Route('/support', name: 'app_support')]
public function index(): Response
{
$data = [
'pageTitle' => 'Web Hosting Support | Little Welsh Hosting Company',
'pageDescription' => ''
];
return $this->render('support/index.html.twig', [
'data' => $data,
]);
}
// ADMIN SECTION
#[Route('/admin/support', name: 'app_admin_support')]
public function list(): Response
{
$tickets = $this->doctrine->getRepository(SupportTickets::class)->findAll();
return $this->render('admin/support/list.html.twig', [
'tickets' => $tickets
]);
}
#[Route('/admin/support/update/{uuid}', name: 'app_admin_support_update')]
public function edit(Request $request, string $uuid): Response
{
$ticket = $this->doctrine->getRepository(SupportTickets::class)->findOneBy([
'uuid' => $uuid
]);
$replies = $this->doctrine->getRepository(SupportTicketReplies::class)->findBy([
'tickets' => $ticket
]);
$now = new \DateTime("now");
$em = $this->doctrine->getManager();
$ticket->setUserRead($now);
$em->flush();
return $this->renderForm('admin/support/edit.html.twig', [
'ticket' => $ticket,
'replies' => $replies,
'repliesForm' => $form,
]);
}
}