diff --git a/migrations/Version20260329000003.php b/migrations/Version20260329000003.php index 92517ff..e675e7c 100644 --- a/migrations/Version20260329000003.php +++ b/migrations/Version20260329000003.php @@ -20,7 +20,7 @@ final class Version20260329000003 extends AbstractMigration public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TABLE notification (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, user_id INT NOT NULL, message VARCHAR(255) NOT NULL, read BOOLEAN NOT NULL DEFAULT false, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE TABLE notification (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, user_id INT NOT NULL, message VARCHAR(255) NOT NULL, is_read BOOLEAN NOT NULL DEFAULT false, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY (id))'); $this->addSql('CREATE INDEX IDX_BF5476CAA76ED395 ON notification (user_id)'); $this->addSql('COMMENT ON COLUMN notification.created_at IS \'(DC2Type:datetime_immutable)\''); $this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CAA76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); diff --git a/src/Controller/ImportController.php b/src/Controller/ImportController.php index 15a292f..2f2db94 100644 --- a/src/Controller/ImportController.php +++ b/src/Controller/ImportController.php @@ -46,6 +46,7 @@ class ImportController extends AbstractController $import = new Import(); $import->setUser($user); + $import->setFilePath('pending'); $em->persist($import); $em->flush(); diff --git a/src/Controller/NotificationController.php b/src/Controller/NotificationController.php index 3412145..9843575 100644 --- a/src/Controller/NotificationController.php +++ b/src/Controller/NotificationController.php @@ -37,13 +37,13 @@ class NotificationController extends AbstractController #[Route('/api/notifications/read', methods: ['POST'])] #[IsGranted('ROLE_USER')] - public function markRead(NotificationRepository $notificationRepository): JsonResponse + public function markRead(NotificationRepository $notificationRepository): Response { /** @var User $user */ $user = $this->getUser(); $notificationRepository->markAllReadForUser($user); - return $this->json(null, Response::HTTP_NO_CONTENT); + return new Response('', Response::HTTP_NO_CONTENT); } } diff --git a/src/Entity/Notification.php b/src/Entity/Notification.php index 66bdc32..fa2503c 100644 --- a/src/Entity/Notification.php +++ b/src/Entity/Notification.php @@ -22,7 +22,7 @@ class Notification #[ORM\Column(length: 255)] private ?string $message = null; - #[ORM\Column] + #[ORM\Column(name: 'is_read')] private bool $read = false; #[ORM\Column] diff --git a/src/Repository/ImportRepository.php b/src/Repository/ImportRepository.php index d154f27..a5529f8 100644 --- a/src/Repository/ImportRepository.php +++ b/src/Repository/ImportRepository.php @@ -20,13 +20,8 @@ class ImportRepository extends ServiceEntityRepository public function incrementProcessedBatches(Import $import): int { - $this->getEntityManager()->getConnection()->executeStatement( - 'UPDATE import SET processed_batches = processed_batches + 1 WHERE id = :id', - ['id' => $import->getId()] - ); - return (int) $this->getEntityManager()->getConnection()->fetchOne( - 'SELECT processed_batches FROM import WHERE id = :id', + 'UPDATE import SET processed_batches = processed_batches + 1 WHERE id = :id RETURNING processed_batches', ['id' => $import->getId()] ); } diff --git a/templates/_navbar.html.twig b/templates/_navbar.html.twig index 83ea4b2..7379582 100644 --- a/templates/_navbar.html.twig +++ b/templates/_navbar.html.twig @@ -1,4 +1,5 @@ {% if app.user %} +
{# Import Modal #} - {% endif %}