Commit 7e5951e8 authored by Tondon César's avatar Tondon César
Browse files

partie 4 refait alors

parent 5c290c5f
......@@ -25,9 +25,6 @@ $app->get('/api/games/',function() {
IndexController::partie2();
})->name('partie2');
$app->get('/partie4',function(){
IndexController::partie4($id);
})->name('partie4');
......
......@@ -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
<?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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment