Added messages, notifications, count, and supporting elements

This commit is contained in:
2024-12-22 01:13:28 +00:00
parent 2b8682bcbb
commit 6b61d1a182
14 changed files with 593 additions and 33 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Controller;
use App\Entity\Messages;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
class MessageController extends AbstractController
{
public function __construct(
private EntityManagerInterface $entityManager
) {
}
#[Route('/api/notifications/{msgId}', name: 'app_read_message')]
public function readMessage(string $msgId): Response
{
$message = $this->entityManager->getRepository(Messages::class)->find($msgId);
$message->setReceived(new \DateTimeImmutable());
$this->entityManager->flush();
return new JsonResponse(true, Response::HTTP_OK);
}
}