From 797cbedb27ed228150aa97b3a458e0e5eacc6346 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 17 Aug 2023 15:53:58 +0200 Subject: [PATCH] Add route to create book --- app/Controller/HelloWorldController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Controller/HelloWorldController.php b/app/Controller/HelloWorldController.php index ef7a807..0e708a0 100644 --- a/app/Controller/HelloWorldController.php +++ b/app/Controller/HelloWorldController.php @@ -59,4 +59,17 @@ class HelloWorldController return new GenericResponse("DB stuff"); } + + #[Route('/create')] + public function createDb(EntityManager $em): ResponseInterface + { + $books = $em->getRepository(Book::class)->findAll(); + $book = new Book(); + $book->setTitle(sprintf('Book %d', count($books) + 1)); + $em->persist($book); + $em->flush(); + dump($book); + + return new GenericResponse("DB stuff"); + } } \ No newline at end of file