|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Furic\GameEssentials\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Furic\GameEssentials\Models\Game; |
|
6
|
|
|
use App\Http\Controllers\Controller; |
|
|
|
|
|
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
|
|
9
|
|
|
class GameController extends Controller |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Display the specified game resource. |
|
14
|
|
|
* |
|
15
|
|
|
* @param int $id |
|
16
|
|
|
* @return \Illuminate\Http\Response |
|
17
|
|
|
*/ |
|
18
|
|
|
public function show($id) |
|
19
|
|
|
{ |
|
20
|
|
|
try { |
|
21
|
|
|
return response(Game::findOrFail($id), 200); |
|
22
|
|
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { |
|
23
|
|
|
return response([ |
|
24
|
|
|
'error' => 'Game not found.' |
|
25
|
|
|
], 400); |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Display the versions of a specified game resource. |
|
31
|
|
|
* |
|
32
|
|
|
* @param int $id |
|
33
|
|
|
* @return \Illuminate\Http\Response |
|
34
|
|
|
*/ |
|
35
|
|
|
public function showVersions($id) // Depricated |
|
36
|
|
|
{ |
|
37
|
|
|
try { |
|
38
|
|
|
$game = Game::findOrFail($id); |
|
39
|
|
|
return response([ |
|
40
|
|
|
'ios' => $game->version_ios, |
|
41
|
|
|
'android' => $game->version_android, |
|
42
|
|
|
'tvos' => $game->version_tvos |
|
43
|
|
|
], 200); |
|
44
|
|
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { |
|
45
|
|
|
return response([ |
|
46
|
|
|
'error' => 'Game not found.' |
|
47
|
|
|
], 400); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Display a listing of the player resource by a given game ID. |
|
53
|
|
|
* |
|
54
|
|
|
* @param Request $request |
|
55
|
|
|
* @param int $id |
|
56
|
|
|
* @return \Illuminate\Http\Response |
|
57
|
|
|
*/ |
|
58
|
|
|
public function showPlayers(Request $request, $id) |
|
59
|
|
|
{ |
|
60
|
|
|
try { |
|
61
|
|
|
if ($request->filled('limit') && $request->limit > 0) { |
|
62
|
|
|
return response(Game::findOrFail($id)->players()->take($request->limit)->get(), 200); |
|
63
|
|
|
} else { |
|
64
|
|
|
return response(Game::findOrFail($id)->players()->take(100)->get(), 200); // Max 100 records to avoid memory exhauseted |
|
65
|
|
|
} |
|
66
|
|
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { |
|
67
|
|
|
return response([ |
|
68
|
|
|
'error' => 'Game not found.' |
|
69
|
|
|
], 400); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths