1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* rmarchiv.tk |
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace App\Http\Controllers\Api\v1; |
9
|
|
|
|
10
|
|
|
use Carbon\Carbon; |
11
|
|
|
use App\Models\Game; |
12
|
|
|
use App\Models\GamesDeveloper; |
13
|
|
|
use Dingo\Api\Routing\Helpers; |
14
|
|
|
use App\Http\Controllers\Controller; |
15
|
|
|
|
16
|
|
|
class GameController extends Controller |
17
|
|
|
{ |
18
|
|
|
use Helpers; |
19
|
|
|
|
20
|
|
|
public function index() |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
$games = Game::select([ |
23
|
|
|
'id', |
24
|
|
|
'title', |
25
|
|
|
'subtitle', |
26
|
|
|
]) |
27
|
|
|
->get(); |
28
|
|
|
|
29
|
|
|
return $games; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function show($id) |
33
|
|
|
{ |
34
|
|
|
//Lade Spielinformationen |
35
|
|
|
$game = Game::whereId($id)->first(); |
36
|
|
|
|
37
|
|
|
//Fülle Array |
38
|
|
|
$array = [ |
39
|
|
|
'type' => 'RpgGame', |
40
|
|
|
'version' => 'rmapi_v1', |
41
|
|
|
'data_date' => Carbon::now()->toDateTimeString(), |
42
|
|
|
'game' => [ |
43
|
|
|
'title' => $game->title, |
44
|
|
|
'subtitle' => $game->subtitle, |
45
|
|
|
'release_date' => $game->release_date, |
46
|
|
|
'developers' => '', |
47
|
|
|
'language' => $game->language->short, |
48
|
|
|
'engine' => $game->maker->short, |
49
|
|
|
], |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
//Lade Entwickler |
53
|
|
|
$developer = GamesDeveloper::whereGameId($id)->get(); |
|
|
|
|
54
|
|
|
$t = []; |
|
|
|
|
55
|
|
|
foreach ($developer as $dev) { |
56
|
|
|
$t[] = $dev->developer->name; |
57
|
|
|
} |
58
|
|
|
$array['game']['developer'] = $t; |
59
|
|
|
|
60
|
|
|
//Lade Tags |
61
|
|
|
|
62
|
|
|
return $array; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function show_app() |
66
|
|
|
{ |
67
|
|
|
$games = Game::with('developers', 'user', 'maker', 'screenshots')->orderBy('created_at')->limit(25)->get(); |
|
|
|
|
68
|
|
|
|
69
|
|
|
$jason = [ |
70
|
|
|
'$jason' => [ |
71
|
|
|
'head' => [ |
72
|
|
|
'title' => 'rmarchiv', |
73
|
|
|
'description' => 'description', |
74
|
|
|
'offline' => true, |
75
|
|
|
'body' => [ |
76
|
|
|
'type' => 'label', |
77
|
|
|
'text' => 'Dies ist Zeile 1', |
78
|
|
|
'style' => [ |
79
|
|
|
'font' => 'HelveticaNeue', |
80
|
|
|
'size' => 20, |
81
|
|
|
'color' => '#ff0000', |
82
|
|
|
'padding' => '10', |
83
|
|
|
], |
84
|
|
|
], |
85
|
|
|
], |
86
|
|
|
], |
87
|
|
|
]; |
88
|
|
|
|
89
|
|
|
return $jason; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.