diff --git a/Seance5-6/seance/index.php b/Seance5-6/seance/index.php index fea1236f22ccc8993deffd80133e1cd600857f77..c028f9ccca3ceff6c304fde176f1d29cb90bf42d 100644 --- a/Seance5-6/seance/index.php +++ b/Seance5-6/seance/index.php @@ -25,6 +25,10 @@ $app->get('/api/games/',function() { IndexController::partie2(); })->name('partie2'); +$app->get('/api/games/:id/comments',function() { + IndexController::partie5(); +})->name('partie5'); + diff --git a/Seance5-6/seance/src/controller/IndexController.php b/Seance5-6/seance/src/controller/IndexController.php index 9688da3f0b3b3cc3ab7b2b49a9d0c897d2fdf822..ee94bb7bc95543c8ef0b3af27afe7d4a428ad1e5 100644 --- a/Seance5-6/seance/src/controller/IndexController.php +++ b/Seance5-6/seance/src/controller/IndexController.php @@ -62,5 +62,22 @@ class IndexController $cq2->render();*/ } + public static function partie5($id){ + $comment = Commentary::select('id', 'titre', 'contenu', 'dateCreation', 'userID')->where('jeuConcerne', '=', $id)->get(); + + $json = '{ "comments" : ['; + foreach ($comment as $c){ + + if($c === array_key_last($$comment)){ + $json = $json . ']}'; + }else{ + $json = $json . json_encode($c) . ','; + } + + } + + $vue = new VuePartie2($json); + $vue->render(); + } } \ No newline at end of file