Added messages, notifications, count, and supporting elements
This commit is contained in:
30
src/Controller/MessageController.php
Normal file
30
src/Controller/MessageController.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user