From 4a4687d4811fe9eee6f88d3007d29c3fc1578300 Mon Sep 17 00:00:00 2001
From: jelassiahmed <47889856+jelassiahmed@users.noreply.github.com>
Date: Thu, 4 Mar 2021 00:43:56 +0100
Subject: [PATCH 1/7] Add files via upload
initial commit + integrated template + working create and read
---
migrations/Version20210303130124.php | 35 ++++
src/Controller/GerantController.php | 45 ++++
src/Controller/HomeController.php | 10 +-
src/Entity/Gerant.php | 116 +++++++++++
src/Form/GerantType.php | 30 +++
src/Kernel.php | 2 -
src/Repository/GerantRepository.php | 50 +++++
templates/base.html.twig | 282 +++++++++++---------------
templates/gerant/addGerant.html.twig | 80 ++++++++
templates/gerant/index.html.twig | 20 ++
templates/gerant/listGerant.html.twig | 36 ++++
templates/home/index.html.twig | 30 +++
12 files changed, 569 insertions(+), 167 deletions(-)
create mode 100644 migrations/Version20210303130124.php
create mode 100644 src/Controller/GerantController.php
create mode 100644 src/Entity/Gerant.php
create mode 100644 src/Form/GerantType.php
create mode 100644 src/Repository/GerantRepository.php
create mode 100644 templates/gerant/addGerant.html.twig
create mode 100644 templates/gerant/index.html.twig
create mode 100644 templates/gerant/listGerant.html.twig
create mode 100644 templates/home/index.html.twig
diff --git a/migrations/Version20210303130124.php b/migrations/Version20210303130124.php
new file mode 100644
index 0000000..e3054ed
--- /dev/null
+++ b/migrations/Version20210303130124.php
@@ -0,0 +1,35 @@
+abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('CREATE TABLE gerant (id_gerant VARCHAR(16) NOT NULL, nom VARCHAR(10) NOT NULL, prenom VARCHAR(10) NOT NULL, date_nais DATE NOT NULL, ad_email VARCHAR(50) NOT NULL, cin VARCHAR(8) NOT NULL, PRIMARY KEY(id_gerant)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
+ }
+
+ public function down(Schema $schema) : void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('DROP TABLE gerant');
+ }
+}
diff --git a/src/Controller/GerantController.php b/src/Controller/GerantController.php
new file mode 100644
index 0000000..7cb995a
--- /dev/null
+++ b/src/Controller/GerantController.php
@@ -0,0 +1,45 @@
+getDoctrine()->getRepository(Gerant::class)->findAll();
+ return $this->render('gerant/listGerant.html.twig', array('gerants' => $gerants));
+ }
+
+ /**
+ * @return Response
+ * @Route ("/add",name="addGerant")
+ */
+ public function addGerant(Request $request){
+ $gerant=new Gerant();
+ $form=$this->createForm(GerantType::class,$gerant);
+ $form->add('ajouter',SubmitType::class,['attr'=>
+ ['class'=>'btn_3']]);
+ $form->handleRequest($request);
+ if($form->isSubmitted()){
+ $em=$this->getDoctrine()->getManager();
+ $em->persist($gerant);
+ $em->flush();
+ return $this->redirectToRoute('gerant');
+ }
+ return $this->render("gerant/addGerant.html.twig",['form'=>$form->createView()]);
+ }
+ public function showGerant(){
+
+ }
+}
diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php
index e3dedc9..365ae8e 100644
--- a/src/Controller/HomeController.php
+++ b/src/Controller/HomeController.php
@@ -8,16 +8,12 @@
class HomeController extends AbstractController
{
-
-
-
-
/**
- * @Route("/test", name="test")
+ * @Route("/", name="home")
*/
- public function test(): Response
+ public function index(): Response
{
- return $this->render('test.html.twig', [
+ return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',
]);
}
diff --git a/src/Entity/Gerant.php b/src/Entity/Gerant.php
new file mode 100644
index 0000000..ba6b50a
--- /dev/null
+++ b/src/Entity/Gerant.php
@@ -0,0 +1,116 @@
+Id_gerant;
+ }
+
+ public function setIdGerant(string $Id_gerant): self
+ {
+ $this->Id_gerant = $Id_gerant;
+
+ return $this;
+ }
+
+ public function getNom(): ?string
+ {
+ return $this->Nom;
+ }
+
+ public function setNom(string $Nom): self
+ {
+ $this->Nom = $Nom;
+
+ return $this;
+ }
+
+ public function getPrenom(): ?string
+ {
+ return $this->Prenom;
+ }
+
+ public function setPrenom(string $Prenom): self
+ {
+ $this->Prenom = $Prenom;
+
+ return $this;
+ }
+
+ public function getDateNais(): ?\DateTimeInterface
+ {
+ return $this->Date_nais;
+ }
+
+ public function setDateNais(\DateTimeInterface $Date_nais): self
+ {
+ $this->Date_nais = $Date_nais;
+
+ return $this;
+ }
+
+ public function getAdEmail(): ?string
+ {
+ return $this->Ad_Email;
+ }
+
+ public function setAdEmail(string $Ad_Email): self
+ {
+ $this->Ad_Email = $Ad_Email;
+
+ return $this;
+ }
+
+ public function getCin(): ?string
+ {
+ return $this->Cin;
+ }
+
+ public function setCin(string $Cin): self
+ {
+ $this->Cin = $Cin;
+
+ return $this;
+ }
+}
diff --git a/src/Form/GerantType.php b/src/Form/GerantType.php
new file mode 100644
index 0000000..4fadc7a
--- /dev/null
+++ b/src/Form/GerantType.php
@@ -0,0 +1,30 @@
+add('Id_gerant')
+ ->add('Nom')
+ ->add('Prenom')
+ ->add('Date_nais')
+ ->add('Ad_Email')
+ ->add('Cin')
+ ;
+ }
+
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults([
+ 'data_class' => Gerant::class,
+ ]);
+ }
+}
diff --git a/src/Kernel.php b/src/Kernel.php
index ee3343b..1cd0572 100644
--- a/src/Kernel.php
+++ b/src/Kernel.php
@@ -23,8 +23,6 @@ public function registerBundles(): iterable
yield new $class();
}
}
-
-
}
public function getProjectDir(): string
diff --git a/src/Repository/GerantRepository.php b/src/Repository/GerantRepository.php
new file mode 100644
index 0000000..164505c
--- /dev/null
+++ b/src/Repository/GerantRepository.php
@@ -0,0 +1,50 @@
+createQueryBuilder('g')
+ ->andWhere('g.exampleField = :val')
+ ->setParameter('val', $value)
+ ->orderBy('g.id', 'ASC')
+ ->setMaxResults(10)
+ ->getQuery()
+ ->getResult()
+ ;
+ }
+ */
+
+ /*
+ public function findOneBySomeField($value): ?Gerant
+ {
+ return $this->createQueryBuilder('g')
+ ->andWhere('g.exampleField = :val')
+ ->setParameter('val', $value)
+ ->getQuery()
+ ->getOneOrNullResult()
+ ;
+ }
+ */
+}
diff --git a/templates/base.html.twig b/templates/base.html.twig
index b7365fa..9102023 100644
--- a/templates/base.html.twig
+++ b/templates/base.html.twig
@@ -1,175 +1,94 @@
-
+
- {% block title %}Welcome!{% endblock %}
+ {% block title %} {% endblock %}
-
- {% block stylesheets %}
-
- {#{{ encore_entry_link_tags('app') }}#}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% endblock %}
-
- {% block javascripts %}
-
-
-
-
- {% endblock %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- {% block preloader %} {% endblock preloader %}
-