diff --git a/migrations/Version20240605084350.php b/migrations/Version20240605084350.php new file mode 100644 index 0000000..6f3e579 --- /dev/null +++ b/migrations/Version20240605084350.php @@ -0,0 +1,44 @@ +addSql('CREATE TABLE post (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, species_id INTEGER DEFAULT NULL, found_date DATETIME NOT NULL --(DC2Type:datetime_immutable) + , publication_date DATETIME NOT NULL --(DC2Type:datetime_immutable) + , latitude DOUBLE PRECISION DEFAULT NULL, longitude DOUBLE PRECISION DEFAULT NULL, altitude DOUBLE PRECISION DEFAULT NULL, commentary CLOB NOT NULL, CONSTRAINT FK_5A8A6C8DB2A1D860 FOREIGN KEY (species_id) REFERENCES species (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); + $this->addSql('CREATE INDEX IDX_5A8A6C8DB2A1D860 ON post (species_id)'); + $this->addSql('CREATE TABLE species (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, scientific_name VARCHAR(255) NOT NULL, vernacular_name VARCHAR(255) NOT NULL, region VARCHAR(255) NOT NULL)'); + $this->addSql('CREATE TABLE messenger_messages (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, body CLOB NOT NULL, headers CLOB NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL --(DC2Type:datetime_immutable) + , available_at DATETIME NOT NULL --(DC2Type:datetime_immutable) + , delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) + )'); + $this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)'); + $this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)'); + $this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE post'); + $this->addSql('DROP TABLE species'); + $this->addSql('DROP TABLE messenger_messages'); + } +} diff --git a/src/Controller/SpeciesController.php b/src/Controller/SpeciesController.php index 6a3d410..e548d2c 100644 --- a/src/Controller/SpeciesController.php +++ b/src/Controller/SpeciesController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Repository\SpeciesRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; @@ -9,10 +10,11 @@ use Symfony\Component\Routing\Attribute\Route; class SpeciesController extends AbstractController { #[Route('/species', name: 'app_species')] - public function index(): Response + public function index(SpeciesRepository $repository): Response { + $species = $repository->findAll(); return $this->render('species/index.html.twig', [ - 'controller_name' => 'SpeciesController', + 'species' => $species, ]); } } diff --git a/templates/species/index.html.twig b/templates/species/index.html.twig index d9f27ea..be8b36a 100644 --- a/templates/species/index.html.twig +++ b/templates/species/index.html.twig @@ -1,6 +1,6 @@ {% extends 'base.html.twig' %} -{% block title %}Hello SpeciesController!{% endblock %} +{% block title %}Herbarium - Espèces{% endblock %} {% block body %}
C:/wamp64/www/Symfony/herbarium/src/Controller/SpeciesController.php
C:/wamp64/www/Symfony/herbarium/templates/species/index.html.twig