Commit 72302beb authored by KELBERT Paul's avatar KELBERT Paul
Browse files

début partie 1

parent 434e1ebf
RewriteEngine On
#
# RewriteBase indispensable sur webetu :
# RewriteBase /www/username0/mywishlist
#
# Pour interdire l'accès aux répertoires contenant du code
RewriteRule ^sql(/.*|)$ - [NC,F]
RewriteRule ^src(/.*|)$ - [NC,F]
RewriteRule ^vendor(/.*|)$ - [NC,F]
#
# réécriture pour slim
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
......@@ -2,7 +2,7 @@
require 'vendor/autoload.php';
use seance\modele\Game;
use seace\controller\IndexController;
use seance\controller\IndexController;
use Illuminate\Database\Capsule\Manager as DB;
$file = parse_ini_file('conf.ini');
......@@ -14,9 +14,13 @@ $app = new \Slim\Slim();
$app->get('/', function(){
IndexController::test();
echo "page index";
})->name('testIndex');
$app->get('/api/games/:id', function($id){
IndexController::jeuParId($id);
})->name('partie1');
$app->run();
......
<?php
namespace seace\controller;
namespace seance\controller;
use seance\modele\Game;
use seance\reponse\CQuestion1;
use seance\view\VuePartie1;
class IndexController
{
public static function test(){
new CQuestion1();
public static function jeuParId($id){
$game = Game::find($id);
$vue = new VuePartie1($game);
$vue->render();
}
}
\ No newline at end of file
<?php
namespace seance\reponse;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use seance\modele\Character;
use seance\modele\Game;
class CQuestion1
{
public function __construct()
{
echo "<a href='index.php'>Retour au menu</a><br><br>";
$game = Game::find(12342);
$p = $game->appears_in;
foreach ($p as $pers) {
echo $pers->name . " -- " . $pers->deck . "<br>";
}
}
}
\ No newline at end of file
<?php
namespace seance\view;
class VuePartie1
{
private $content;
public function __construct($game)
{
$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>
{
"id": $game->id,
"name": "$game->name",
"alias": "$game->alias",
"deck": "$game->deck",
"description": ...",
"original_release_date": "$game->original_release_date"
}
</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