Add route to create book
This commit is contained in:
parent
7a4a9257c3
commit
797cbedb27
@ -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");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user