diff --git a/Seance5-6/seance/src/controller/IndexController.php b/Seance5-6/seance/src/controller/IndexController.php index 88db463f9b3ce96ff2b416948fd26011fb566ad4..728087ec218361c9a7f27a8a407e7f034ce75fa3 100644 --- a/Seance5-6/seance/src/controller/IndexController.php +++ b/Seance5-6/seance/src/controller/IndexController.php @@ -17,29 +17,31 @@ class IndexController } public static function partie2() { - $game = Game::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 . '{ - "id": ' . $value->id . ', - "name":' . $value->name . ', - "deck":' . $value->deck . ', - }, - '; - if ($value->id == 200) { - $json = $json . '{ - "id": ' . $value->id . ', - "name":' . $value->name . ', - "deck":' . $value->deck . ', - } - '; - } - } - $json = $json . ']}'; - $cq2 = new VuePartie2($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); + $json = '{ "games" : [ '; + foreach($game as $key => $value) { + $json = $json . json_encode($value) . ','; + /*$json = $json . '{ + "id": ' . $value->id . ', + "name":' . $value->name . ', + "deck":' . $value->deck . ', + }, + ';*/ + if ($value->id == 200) { + $json = $json . json_encode($value);/* + $json = $json . '{ + "id": ' . $value->id . ', + "name":' . $value->name . ', + "deck":' . $value->deck . ', + } + ';*/ + } + } + $json = $json . ']}'; + $cq2 = new VuePartie2($json); + $cq2->render(); } } \ No newline at end of file