render('tables/index.html.twig', [ 'tables' => $tablesRepository->findAll(), ]); } #[Route('/new', name: 'app_tables_new', methods: ['GET', 'POST'])] public function new(Request $request, EntityManagerInterface $entityManager): Response { $table = new Tables(); $form = $this->createForm(TablesType::class, $table); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->persist($table); $entityManager->flush(); return $this->redirectToRoute('app_tables_index', [], Response::HTTP_SEE_OTHER); } return $this->render('tables/new.html.twig', [ 'table' => $table, 'form' => $form, ]); } #[Route('/{id}/edit', name: 'app_tables_edit', methods: ['GET', 'POST'])] public function edit(Request $request, Tables $table, EntityManagerInterface $entityManager): Response { $form = $this->createForm(TablesType::class, $table); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->flush(); return $this->redirectToRoute('app_tables_index', [], Response::HTTP_SEE_OTHER); } return $this->render('tables/edit.html.twig', [ 'table' => $table, 'form' => $form, ]); } #[Route('/{id}', name: 'app_tables_delete', methods: ['POST'])] public function delete(Request $request, Tables $table, EntityManagerInterface $entityManager): Response { if ($this->isCsrfTokenValid('delete'.$table->getId(), $request->getPayload()->getString('_token'))) { $entityManager->remove($table); $entityManager->flush(); } return $this->redirectToRoute('app_tables_index', [], Response::HTTP_SEE_OTHER); } }