|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Gameap\Http\Controllers\API; |
|
4
|
|
|
|
|
5
|
|
|
use Gameap\Http\Controllers\AuthController; |
|
6
|
|
|
use Gameap\Repositories\GameModRepository; |
|
7
|
|
|
use Gameap\Models\GameMod; |
|
8
|
|
|
use Illuminate\Http\Request; |
|
9
|
|
|
|
|
10
|
|
|
class GameModsController extends AuthController |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* The GameModRepository instance. |
|
14
|
|
|
* |
|
15
|
|
|
* @var \Gameap\Repositories\GameModRepository |
|
16
|
|
|
*/ |
|
17
|
|
|
public $repository; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* GameModsController constructor. |
|
21
|
|
|
* @param GameModRepository $repository |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct(GameModRepository $repository) |
|
24
|
|
|
{ |
|
25
|
|
|
parent::__construct(); |
|
26
|
|
|
|
|
27
|
|
|
$this->repository = $repository; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function getListForGame(string $gameCode) |
|
31
|
|
|
{ |
|
32
|
|
|
return $this->repository->getIdNameListForGame($gameCode); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function index() |
|
36
|
|
|
{ |
|
37
|
|
|
$game_mods = GameMod::all(); |
|
38
|
|
|
|
|
39
|
|
|
return response()->json($game_mods); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function store(Request $request) |
|
43
|
|
|
{ |
|
44
|
|
|
$game_mod = GameMod::create($request->all()); |
|
45
|
|
|
|
|
46
|
|
|
return response()->json($game_mod, 201); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function show(GameMod $game_mod) |
|
50
|
|
|
{ |
|
51
|
|
|
return response()->json($game_mod); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function update(Request $request, GameMod $game_mod) |
|
55
|
|
|
{ |
|
56
|
|
|
$game_mod->update($request->all()); |
|
57
|
|
|
|
|
58
|
|
|
return response()->json($game_mod, 200); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function destroy(GameMod $game_mod) |
|
62
|
|
|
{ |
|
63
|
|
|
$game_mod->delete(); |
|
64
|
|
|
|
|
65
|
|
|
return response()->json(null, 204); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|