From 7e5951e8ac14214ded1957ed25d35471e2fcbc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tondon=20C=C3=A9sar?= <pilou.tondon@hotmail.fr> Date: Wed, 25 Mar 2020 11:00:41 +0100 Subject: [PATCH] partie 4 refait alors --- Seance5-6/seance/index.php | 3 -- .../seance/src/controller/IndexController.php | 23 ++++++---- Seance5-6/seance/src/view/VuePartie4.php | 42 ------------------- 3 files changed, 15 insertions(+), 53 deletions(-) delete mode 100644 Seance5-6/seance/src/view/VuePartie4.php diff --git a/Seance5-6/seance/index.php b/Seance5-6/seance/index.php index c4bd7c1..fea1236 100644 --- a/Seance5-6/seance/index.php +++ b/Seance5-6/seance/index.php @@ -25,9 +25,6 @@ $app->get('/api/games/',function() { IndexController::partie2(); })->name('partie2'); -$app->get('/partie4',function(){ - IndexController::partie4($id); -})->name('partie4'); diff --git a/Seance5-6/seance/src/controller/IndexController.php b/Seance5-6/seance/src/controller/IndexController.php index 4505ac9..0f0949f 100644 --- a/Seance5-6/seance/src/controller/IndexController.php +++ b/Seance5-6/seance/src/controller/IndexController.php @@ -17,6 +17,19 @@ class IndexController } public static function partie2() { + + $game = Game::select('id','name','alias','deck')->where('id','<=','200')->get(); + // $game = Game::where('id','=',1)->get(); + // $json = json_encode($game,JSON_FORCE_OBJECT); + $json = '{ "games" : [ '; + foreach($game as $key => $value) { + $json = $json . '"game" :{'; + $json = $json . json_encode($value) . ',},"links" :{"self": {"href":"/api/games/'.$value->id.'"}}'; + } + $json = $json . ']}'; + $cq2 = new CQuestion2($json); + $cq2->render(); + /* $game = Game::select('id','name','alias','deck')->where('id','<=','200')->get(); // $game = Game::where('id','=',1)->get(); // $json = json_encode($game,JSON_FORCE_OBJECT); @@ -36,19 +49,13 @@ class IndexController "name":' . $value->name . ', "deck":' . $value->deck . ', } - ';*/ + '; } } $json = $json . ']}'; $cq2 = new VuePartie2($json); - $cq2->render(); + $cq2->render();*/ } - public static function partie4($id){ - $game = Game::find($id); - - $vue = new VuePartie4($game); - $vue->render(); - } } \ No newline at end of file diff --git a/Seance5-6/seance/src/view/VuePartie4.php b/Seance5-6/seance/src/view/VuePartie4.php deleted file mode 100644 index 59a74e9..0000000 --- a/Seance5-6/seance/src/view/VuePartie4.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace seance\view; -class VuePartie4 -{ - - private $content; - - public function __construct($game) - { - $game->description = "..."; - $json = json_encode($game); - $json = $json . '"links" : { - "self" : { "href" : "/api/games/'.$game->id.'"}'; - - $this->content = <<< END - <!DOCTYPE html> - <html lang="fr"> - <head> - <meta charset="UTF-8" content="application/json"> - - <link rel="stylesheet" href="css/main.css"> - - <title>photobox</title> - </head> - - <body> - - $json - - </body> - -END; - - } - - public function render() - { - echo $this->content; - } - -} \ No newline at end of file -- GitLab