diff --git a/src/Controller/CategorieController.php b/src/Controller/CategorieController.php new file mode 100644 index 0000000..3bac84d --- /dev/null +++ b/src/Controller/CategorieController.php @@ -0,0 +1,81 @@ +render('categorie/index.html.twig', [ + 'categories' => $categorieRepository->findAll(), + ]); + } + + #[Route('/new', name: 'app_categorie_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $categorie = new Categorie(); + $form = $this->createForm(CategorieType::class, $categorie); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($categorie); + $entityManager->flush(); + + return $this->redirectToRoute('app_categorie_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('categorie/new.html.twig', [ + 'categorie' => $categorie, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_categorie_show', methods: ['GET'])] + public function show(Categorie $categorie): Response + { + return $this->render('categorie/show.html.twig', [ + 'categorie' => $categorie, + ]); + } + + #[Route('/{id}/edit', name: 'app_categorie_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Categorie $categorie, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(CategorieType::class, $categorie); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_categorie_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('categorie/edit.html.twig', [ + 'categorie' => $categorie, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_categorie_delete', methods: ['POST'])] + public function delete(Request $request, Categorie $categorie, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$categorie->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($categorie); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_categorie_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Controller/MenuController.php b/src/Controller/MenuController.php new file mode 100644 index 0000000..69fbd3d --- /dev/null +++ b/src/Controller/MenuController.php @@ -0,0 +1,81 @@ +render('menu/index.html.twig', [ + 'menus' => $menuRepository->findAll(), + ]); + } + + #[Route('/new', name: 'app_menu_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $menu = new Menu(); + $form = $this->createForm(MenuType::class, $menu); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($menu); + $entityManager->flush(); + + return $this->redirectToRoute('app_menu_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('menu/new.html.twig', [ + 'menu' => $menu, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_menu_show', methods: ['GET'])] + public function show(Menu $menu): Response + { + return $this->render('menu/show.html.twig', [ + 'menu' => $menu, + ]); + } + + #[Route('/{id}/edit', name: 'app_menu_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Menu $menu, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(MenuType::class, $menu); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_menu_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('menu/edit.html.twig', [ + 'menu' => $menu, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_menu_delete', methods: ['POST'])] + public function delete(Request $request, Menu $menu, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$menu->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($menu); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_menu_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Controller/PlatController.php b/src/Controller/PlatController.php new file mode 100644 index 0000000..34bba4c --- /dev/null +++ b/src/Controller/PlatController.php @@ -0,0 +1,81 @@ +render('plat/index.html.twig', [ + 'plats' => $platRepository->findAll(), + ]); + } + + #[Route('/new', name: 'app_plat_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $plat = new Plat(); + $form = $this->createForm(PlatType::class, $plat); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($plat); + $entityManager->flush(); + + return $this->redirectToRoute('app_plat_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('plat/new.html.twig', [ + 'plat' => $plat, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_plat_show', methods: ['GET'])] + public function show(Plat $plat): Response + { + return $this->render('plat/show.html.twig', [ + 'plat' => $plat, + ]); + } + + #[Route('/{id}/edit', name: 'app_plat_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Plat $plat, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(PlatType::class, $plat); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_plat_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('plat/edit.html.twig', [ + 'plat' => $plat, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_plat_delete', methods: ['POST'])] + public function delete(Request $request, Plat $plat, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$plat->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($plat); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_plat_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Controller/RestaurantController.php b/src/Controller/RestaurantController.php new file mode 100644 index 0000000..89b0f67 --- /dev/null +++ b/src/Controller/RestaurantController.php @@ -0,0 +1,81 @@ +render('restaurant/index.html.twig', [ + 'restaurants' => $restaurantRepository->findAll(), + ]); + } + + #[Route('/new', name: 'app_restaurant_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $restaurant = new Restaurant(); + $form = $this->createForm(RestaurantType::class, $restaurant); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($restaurant); + $entityManager->flush(); + + return $this->redirectToRoute('app_restaurant_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('restaurant/new.html.twig', [ + 'restaurant' => $restaurant, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_restaurant_show', methods: ['GET'])] + public function show(Restaurant $restaurant): Response + { + return $this->render('restaurant/show.html.twig', [ + 'restaurant' => $restaurant, + ]); + } + + #[Route('/{id}/edit', name: 'app_restaurant_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Restaurant $restaurant, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(RestaurantType::class, $restaurant); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_restaurant_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('restaurant/edit.html.twig', [ + 'restaurant' => $restaurant, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_restaurant_delete', methods: ['POST'])] + public function delete(Request $request, Restaurant $restaurant, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$restaurant->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($restaurant); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_restaurant_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Form/CategorieType.php b/src/Form/CategorieType.php new file mode 100644 index 0000000..4cdb938 --- /dev/null +++ b/src/Form/CategorieType.php @@ -0,0 +1,25 @@ +add('nom') + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Categorie::class, + ]); + } +} diff --git a/src/Form/MenuType.php b/src/Form/MenuType.php new file mode 100644 index 0000000..01fd8ac --- /dev/null +++ b/src/Form/MenuType.php @@ -0,0 +1,40 @@ +add('nom') + ->add('dateDeCreation', null, [ + 'widget' => 'single_text', + ]) + ->add('plats', EntityType::class, [ + 'class' => plat::class, + 'choice_label' => 'id', + 'multiple' => true, + ]) + ->add('restaurant', EntityType::class, [ + 'class' => Restaurant::class, + 'choice_label' => 'id', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Menu::class, + ]); + } +} diff --git a/src/Form/PlatType.php b/src/Form/PlatType.php new file mode 100644 index 0000000..709496d --- /dev/null +++ b/src/Form/PlatType.php @@ -0,0 +1,39 @@ +add('nom') + ->add('description') + ->add('prix') + ->add('categorie', EntityType::class, [ + 'class' => categorie::class, + 'choice_label' => 'id', + ]) + ->add('menus', EntityType::class, [ + 'class' => Menu::class, + 'choice_label' => 'id', + 'multiple' => true, + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Plat::class, + ]); + } +} diff --git a/src/Form/RestaurantType.php b/src/Form/RestaurantType.php new file mode 100644 index 0000000..eda9476 --- /dev/null +++ b/src/Form/RestaurantType.php @@ -0,0 +1,28 @@ +add('nom') + ->add('adresse') + ->add('telephone') + ->add('chef') + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Restaurant::class, + ]); + } +} diff --git a/templates/categorie/_delete_form.html.twig b/templates/categorie/_delete_form.html.twig new file mode 100644 index 0000000..807504c --- /dev/null +++ b/templates/categorie/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/categorie/_form.html.twig b/templates/categorie/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/categorie/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/categorie/edit.html.twig b/templates/categorie/edit.html.twig new file mode 100644 index 0000000..664578a --- /dev/null +++ b/templates/categorie/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Categorie{% endblock %} + +{% block body %} +

Edit Categorie

+ + {{ include('categorie/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('categorie/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/categorie/index.html.twig b/templates/categorie/index.html.twig new file mode 100644 index 0000000..9f679f4 --- /dev/null +++ b/templates/categorie/index.html.twig @@ -0,0 +1,35 @@ +{% extends 'base.html.twig' %} + +{% block title %}Categorie index{% endblock %} + +{% block body %} +

Categorie index

+ + + + + + + + + + + {% for categorie in categories %} + + + + + + {% else %} + + + + {% endfor %} + +
IdNomactions
{{ categorie.id }}{{ categorie.nom }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/categorie/new.html.twig b/templates/categorie/new.html.twig new file mode 100644 index 0000000..b0ae246 --- /dev/null +++ b/templates/categorie/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Categorie{% endblock %} + +{% block body %} +

Create new Categorie

+ + {{ include('categorie/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/categorie/show.html.twig b/templates/categorie/show.html.twig new file mode 100644 index 0000000..047935c --- /dev/null +++ b/templates/categorie/show.html.twig @@ -0,0 +1,26 @@ +{% extends 'base.html.twig' %} + +{% block title %}Categorie{% endblock %} + +{% block body %} +

Categorie

+ + + + + + + + + + + + +
Id{{ categorie.id }}
Nom{{ categorie.nom }}
+ + back to list + + edit + + {{ include('categorie/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/menu/_delete_form.html.twig b/templates/menu/_delete_form.html.twig new file mode 100644 index 0000000..6669b18 --- /dev/null +++ b/templates/menu/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/menu/_form.html.twig b/templates/menu/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/menu/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/menu/edit.html.twig b/templates/menu/edit.html.twig new file mode 100644 index 0000000..9edc4ed --- /dev/null +++ b/templates/menu/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Menu{% endblock %} + +{% block body %} +

Edit Menu

+ + {{ include('menu/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('menu/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/menu/index.html.twig b/templates/menu/index.html.twig new file mode 100644 index 0000000..3413819 --- /dev/null +++ b/templates/menu/index.html.twig @@ -0,0 +1,37 @@ +{% extends 'base.html.twig' %} + +{% block title %}Menu index{% endblock %} + +{% block body %} +

Menu index

+ + + + + + + + + + + + {% for menu in menus %} + + + + + + + {% else %} + + + + {% endfor %} + +
IdNomDateDeCreationactions
{{ menu.id }}{{ menu.nom }}{{ menu.dateDeCreation ? menu.dateDeCreation|date('Y-m-d H:i:s') : '' }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/menu/new.html.twig b/templates/menu/new.html.twig new file mode 100644 index 0000000..61d0dc4 --- /dev/null +++ b/templates/menu/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Menu{% endblock %} + +{% block body %} +

Create new Menu

+ + {{ include('menu/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/menu/show.html.twig b/templates/menu/show.html.twig new file mode 100644 index 0000000..3535f74 --- /dev/null +++ b/templates/menu/show.html.twig @@ -0,0 +1,30 @@ +{% extends 'base.html.twig' %} + +{% block title %}Menu{% endblock %} + +{% block body %} +

Menu

+ + + + + + + + + + + + + + + + +
Id{{ menu.id }}
Nom{{ menu.nom }}
DateDeCreation{{ menu.dateDeCreation ? menu.dateDeCreation|date('Y-m-d H:i:s') : '' }}
+ + back to list + + edit + + {{ include('menu/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/plat/_delete_form.html.twig b/templates/plat/_delete_form.html.twig new file mode 100644 index 0000000..e522d7f --- /dev/null +++ b/templates/plat/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/plat/_form.html.twig b/templates/plat/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/plat/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/plat/edit.html.twig b/templates/plat/edit.html.twig new file mode 100644 index 0000000..3715dc1 --- /dev/null +++ b/templates/plat/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Plat{% endblock %} + +{% block body %} +

Edit Plat

+ + {{ include('plat/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('plat/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/plat/index.html.twig b/templates/plat/index.html.twig new file mode 100644 index 0000000..9c4ec94 --- /dev/null +++ b/templates/plat/index.html.twig @@ -0,0 +1,39 @@ +{% extends 'base.html.twig' %} + +{% block title %}Plat index{% endblock %} + +{% block body %} +

Plat index

+ + + + + + + + + + + + + {% for plat in plats %} + + + + + + + + {% else %} + + + + {% endfor %} + +
IdNomDescriptionPrixactions
{{ plat.id }}{{ plat.nom }}{{ plat.description }}{{ plat.prix }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/plat/new.html.twig b/templates/plat/new.html.twig new file mode 100644 index 0000000..91d948c --- /dev/null +++ b/templates/plat/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Plat{% endblock %} + +{% block body %} +

Create new Plat

+ + {{ include('plat/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/plat/show.html.twig b/templates/plat/show.html.twig new file mode 100644 index 0000000..01c1fa2 --- /dev/null +++ b/templates/plat/show.html.twig @@ -0,0 +1,34 @@ +{% extends 'base.html.twig' %} + +{% block title %}Plat{% endblock %} + +{% block body %} +

Plat

+ + + + + + + + + + + + + + + + + + + + +
Id{{ plat.id }}
Nom{{ plat.nom }}
Description{{ plat.description }}
Prix{{ plat.prix }}
+ + back to list + + edit + + {{ include('plat/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/restaurant/_delete_form.html.twig b/templates/restaurant/_delete_form.html.twig new file mode 100644 index 0000000..d6a67d4 --- /dev/null +++ b/templates/restaurant/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/restaurant/_form.html.twig b/templates/restaurant/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/restaurant/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/restaurant/edit.html.twig b/templates/restaurant/edit.html.twig new file mode 100644 index 0000000..24a83d2 --- /dev/null +++ b/templates/restaurant/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Restaurant{% endblock %} + +{% block body %} +

Edit Restaurant

+ + {{ include('restaurant/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('restaurant/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/restaurant/index.html.twig b/templates/restaurant/index.html.twig new file mode 100644 index 0000000..85b6ffd --- /dev/null +++ b/templates/restaurant/index.html.twig @@ -0,0 +1,41 @@ +{% extends 'base.html.twig' %} + +{% block title %}Restaurant index{% endblock %} + +{% block body %} +

Restaurant index

+ + + + + + + + + + + + + + {% for restaurant in restaurants %} + + + + + + + + + {% else %} + + + + {% endfor %} + +
IdNomAdresseTelephoneChefactions
{{ restaurant.id }}{{ restaurant.nom }}{{ restaurant.adresse }}{{ restaurant.telephone }}{{ restaurant.chef }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/restaurant/new.html.twig b/templates/restaurant/new.html.twig new file mode 100644 index 0000000..d66ed16 --- /dev/null +++ b/templates/restaurant/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Restaurant{% endblock %} + +{% block body %} +

Create new Restaurant

+ + {{ include('restaurant/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/restaurant/show.html.twig b/templates/restaurant/show.html.twig new file mode 100644 index 0000000..dcc1cd9 --- /dev/null +++ b/templates/restaurant/show.html.twig @@ -0,0 +1,38 @@ +{% extends 'base.html.twig' %} + +{% block title %}Restaurant{% endblock %} + +{% block body %} +

Restaurant

+ + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ restaurant.id }}
Nom{{ restaurant.nom }}
Adresse{{ restaurant.adresse }}
Telephone{{ restaurant.telephone }}
Chef{{ restaurant.chef }}
+ + back to list + + edit + + {{ include('restaurant/_delete_form.html.twig') }} +{% endblock %}