From 08e0d97ef2800dc8607b1a3b4f1c8fcb61d1ad1f Mon Sep 17 00:00:00 2001
From: Safyrus <54881649+Safyrus@users.noreply.github.com>
Date: Wed, 4 Mar 2020 08:51:29 +0100
Subject: [PATCH] modif index + add view

---
 tp1/src/index.php          | 10 ++++--
 tp1/src/vue/RequeteVue.php | 67 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 tp1/src/vue/RequeteVue.php

diff --git a/tp1/src/index.php b/tp1/src/index.php
index efb43c4..5beaad6 100644
--- a/tp1/src/index.php
+++ b/tp1/src/index.php
@@ -1,4 +1,6 @@
 <?php
+
+use bdd\controleur\ControleurRequete;
 use Illuminate\Database\Capsule\Manager as DB;
 $db = new DB();
 //SI CA NE FONCTIONNE PAS, ENLEVER LES COMMENTAIRES : CES INFOS SONT DEJA DANS LE CONF.INI
@@ -30,10 +32,8 @@ $db->addConnection([
 $db->setAsGlobal();
 $db->bootEloquent();
 
-// demerage d'un session
 session_start();
 
-// intance de slim qui a pour but de créer le rootage des urls
 $app = new Slim();
 
 $app->get('/', function () {
@@ -41,15 +41,19 @@ $app->get('/', function () {
     $v->renderHome();
 })->name('accueil');
 $app->get('/ex1/requete1', function () {
-
+    $c = new ControleurRequete();
+    $c->selectMario();
 })->name('ex1 requete 1');
 $app->get('/ex1/requete2', function () {
+    $c = new ControleurRequete();
 
 })->name('ex1 requete 2');
 $app->get('/ex1/requete3', function () {
+    $c = new ControleurRequete();
 
 })->name('ex1 requete 3');
 $app->get('/ex1/requete4', function () {
+    $c = new ControleurRequete();
 
 })->name('ex1 requete 4');
 
diff --git a/tp1/src/vue/RequeteVue.php b/tp1/src/vue/RequeteVue.php
new file mode 100644
index 0000000..a8e7054
--- /dev/null
+++ b/tp1/src/vue/RequeteVue.php
@@ -0,0 +1,67 @@
+<?php
+
+use Slim\Slim;
+
+class Requete1
+{
+
+    protected $tab, $app;
+
+    public function __construct($t)
+    {
+        $this->tab = $t;
+        $this->app = Slim::getInstance();
+    }
+
+    public function render($type)
+    {
+        switch ($type) {
+            case 1:
+                return $this->selectMario();
+                break;
+            default:
+                return $this->notFound();
+                break;
+        }
+    }
+
+    private function notFound()
+    {
+        $res .= <<<RES
+    <!doctype html>
+
+    <html lang="fr">
+    <head>
+        <meta charset="utf-8">
+    </head>
+    <body>
+        <p>data not found</p>
+    </body>
+    </html>
+RES;
+    }
+
+    private function selectMario()
+    {
+        $res .= <<<RES
+    <!doctype html>
+
+    <html lang="fr">
+    <head>
+        <meta charset="utf-8">
+    </head>
+    <body>
+
+RES;
+        foreach ($this->tab as $key => $value) {
+            $res .= <<<RES
+    $key:$value
+RES;
+        }
+        $res .= <<<RES
+    </body>
+    </html>
+RES;
+        return $res;
+    }
+}
-- 
GitLab