Add route to create book

This commit is contained in:
Tim 2023-08-17 15:53:58 +02:00
parent 7a4a9257c3
commit 797cbedb27
1 changed files with 13 additions and 0 deletions

View File

@ -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");
}
}