Skip to content
Snippets Groups Projects
Commit 7d783fa3 authored by SASSU Thomas's avatar SASSU Thomas
Browse files

Partie 4

parent c36bc99b
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,6 @@ $app->get('/api/games/:id',function ($id) { ...@@ -30,6 +30,6 @@ $app->get('/api/games/:id',function ($id) {
$app->get('/api/games/',function () { $app->get('/api/games/',function () {
$c = new ControleurGame(); $c = new ControleurGame();
$c->getGames(); $c->getGames();
}); })->name('getGame');
$app->run(); $app->run();
\ No newline at end of file
...@@ -4,6 +4,8 @@ namespace gp\controleurs; ...@@ -4,6 +4,8 @@ namespace gp\controleurs;
use gp\modeles\Game; use gp\modeles\Game;
use gp\vues\VueGame; use gp\vues\VueGame;
use Slim\Slim;
class ControleurGame class ControleurGame
{ {
public function getGame($id){ public function getGame($id){
...@@ -18,7 +20,9 @@ class ControleurGame ...@@ -18,7 +20,9 @@ class ControleurGame
$response = Game::paginate(200, ['*'], 'page', $page); $response = Game::paginate(200, ['*'], 'page', $page);
$json = (json_decode(json_encode($response),true)); $json = (json_decode(json_encode($response),true));
foreach ($json['data'] as $game) { foreach ($json['data'] as $game) {
$results['games'][] = ["game" => $game, "links" => ["self" => ["href" => "/api/games/{$game['id']}"]]]; $route = explode('bdappli_laurent_vonderscher_sassu_percin/GamePedia',Slim::getInstance()->urlFor('getGame'));
$url = $route[1]."{$game['id']}";
$results['games'][] = ["game" => $game, "links" => ["self" => ["href" => $url]]];
} }
$links = ["prev" =>["href" => "/api/games{$json['prev_page_url']}"] , "next" =>["href" => "/api/games{$json['next_page_url']}"]]; $links = ["prev" =>["href" => "/api/games{$json['prev_page_url']}"] , "next" =>["href" => "/api/games{$json['next_page_url']}"]];
$results['links'] = $links; $results['links'] = $links;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment