From 82a3f69fa42598e2322fbc37f06f3ecf0c72e972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20LAPORTE?= Date: Fri, 7 Jun 2024 15:27:55 +0200 Subject: [PATCH] View (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Création de la page species et detail specie Co-authored-by: Clément Laporte Co-authored-by: clfreville2 Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/8 Co-authored-by: Clément LAPORTE Co-committed-by: Clément LAPORTE --- src/Controller/SpeciesController.php | 29 +++++++++++++++++++ src/DataFixtures/AppFixtures.php | 3 +- templates/species/detail.html.twig | 43 ++++++++++++++++++++++++++++ templates/species/index.html.twig | 29 +++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/Controller/SpeciesController.php create mode 100644 templates/species/detail.html.twig create mode 100644 templates/species/index.html.twig diff --git a/src/Controller/SpeciesController.php b/src/Controller/SpeciesController.php new file mode 100644 index 0000000..e727c11 --- /dev/null +++ b/src/Controller/SpeciesController.php @@ -0,0 +1,29 @@ +findAll(); + return $this->render('species/index.html.twig', [ + 'species' => $species, + ]); + } + + #[Route('/species/{id}', name: 'app_species_detail')] + public function detail(Species $specie): Response + { + return $this->render('species/detail.html.twig', [ + 'specie' => $specie, + ]); + } +} diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index 12d5f40..2fbb47f 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -25,7 +25,8 @@ class AppFixtures extends Fixture ->setPublicationDate($date) ->setLatitude($faker->randomFloat()) ->setLongitude($faker->randomFloat()) - ->setCommentary($faker->text()); + ->setCommentary($faker->text()) + -> setSpecies($species); $manager->persist($species); $manager->persist($post); } diff --git a/templates/species/detail.html.twig b/templates/species/detail.html.twig new file mode 100644 index 0000000..d6a5ebf --- /dev/null +++ b/templates/species/detail.html.twig @@ -0,0 +1,43 @@ +{% extends 'base.html.twig' %} + +{% block title %}Herbarium - Détail de l'espèces{% endblock %} + +{% block body %} + + +
+

{{ specie.vernacularName }}

+

+ 🔬 Nom Scientifique : {{ specie.scientificName }}
+ 📍 Region : {{ specie.region }} +

+
+

Posts :

+ + {% for post in specie.posts %} +
+
+

+ + 📅 {{ post.publicationDate | date }} + +

+
+
+ 📍 géolocalisation :
+ - Longitude : {{ post.longitude }}
+ - Latitude : {{ post.latitude }}
+ - Altitude : {{ post.altitude }}

+ + 💬 Commentaire :
+ - {{ post.getCommentary }} +
+
+ {% endfor %} +
+ +
+{% endblock %} \ No newline at end of file diff --git a/templates/species/index.html.twig b/templates/species/index.html.twig new file mode 100644 index 0000000..666ad41 --- /dev/null +++ b/templates/species/index.html.twig @@ -0,0 +1,29 @@ +{% extends 'base.html.twig' %} + +{% block title %}Herbarium - Espèces{% endblock %} + +{% block body %} + + +
+

Liste des espèces

+ +
+ {% for specie in species %} +
+ + 🌿 {{ specie.getVernacularName }} + +
+
+ 🔬 Nom Scientifique : {{ specie.getScientificName }}
+ 📍 Region : {{ specie.getRegion }} +

+ {% endfor %} +
+ +
+{% endblock %}