Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KELBERT Paul
ApplicationsBD_CHEVALIER_TONDON_KELBERT
Commits
6e9d62d5
Commit
6e9d62d5
authored
Mar 25, 2020
by
Tondon César
Browse files
partie2
parent
ebda51d2
Changes
3
Show whitespace changes
Inline
Side-by-side
Seance5-6/seance/index.php
View file @
6e9d62d5
...
...
@@ -21,6 +21,10 @@ $app->get('/api/games/:id', function($id){
IndexController
::
jeuParId
(
$id
);
})
->
name
(
'partie1'
);
$app
->
get
(
'/api/games/'
,
function
()
{
IndexController
::
partie2
();
})
->
name
(
'partie2'
);
$app
->
run
();
...
...
Seance5-6/seance/src/controller/IndexController.php
View file @
6e9d62d5
...
...
@@ -3,8 +3,8 @@
namespace
seance\controller
;
use
seance\modele\Game
;
use
seance\reponse\CQuestion1
;
use
seance\view\VuePartie1
;
use
seance\view\VuePartie2
;
class
IndexController
{
...
...
@@ -16,4 +16,30 @@ class IndexController
$vue
->
render
();
}
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
();
}
}
\ No newline at end of file
Seance5-6/seance/src/view/VuePartie2.php
0 → 100644
View file @
6e9d62d5
<?php
namespace
seance\view
;
use
Illuminate\Database\Eloquent\ModelNotFoundException
;
use
seance\modele\Character
;
use
seance\modele\Game
;
class
VuePartie2
{
private
$content
;
public
function
__construct
(
$json
)
{
$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
>
<
h1
>
Titre
</
h1
>
<
p
>
$json
</
p
>
</
body
>
END
;
}
public
function
render
()
{
echo
$this
->
content
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment