1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Gameap\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use Gameap\Http\Controllers\AuthController; |
6
|
|
|
use Gameap\Models\Game; |
7
|
|
|
use Gameap\Repositories\GameRepository; |
8
|
|
|
use Gameap\Http\Requests\GameRequest; |
9
|
|
|
|
10
|
|
|
class GamesController extends AuthController |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The GameRepository instance. |
14
|
|
|
* |
15
|
|
|
* @var \Gameap\Repositories\GameRepository |
16
|
|
|
*/ |
17
|
|
|
protected $repository; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Create a new GameController instance. |
21
|
|
|
* |
22
|
|
|
* @param \Gameap\Repositories\GameRepository $repository |
23
|
|
|
*/ |
24
|
|
|
public function __construct(GameRepository $repository) |
25
|
|
|
{ |
26
|
|
|
$this->repository = $repository; |
27
|
|
|
|
28
|
|
|
parent::__construct(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Display a listing of the games. |
33
|
|
|
* |
34
|
|
|
* @return \Illuminate\View\View |
35
|
|
|
*/ |
36
|
|
|
public function index() |
37
|
|
|
{ |
38
|
|
|
return view('admin.games.list',[ |
39
|
|
|
'games' => $this->repository->getAll() |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Display new create game page |
45
|
|
|
* |
46
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
47
|
|
|
*/ |
48
|
|
|
public function create() |
49
|
|
|
{ |
50
|
|
|
return view('admin.games.create'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Store a newly created game in storage. |
55
|
|
|
* |
56
|
|
|
* @param \Gameap\Http\Requests\GameRequest $request |
57
|
|
|
* @return \Illuminate\Http\RedirectResponse |
58
|
|
|
*/ |
59
|
|
|
public function store(GameRequest $request) |
60
|
|
|
{ |
61
|
|
|
Game::create($request->all()); |
62
|
|
|
|
63
|
|
|
return redirect()->route('admin.games.index') |
64
|
|
|
->with('success', __('games.create_success_msg')); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Display the specified resource. |
69
|
|
|
* |
70
|
|
|
* @param \Gameap\Models\Game $game |
71
|
|
|
* @return \Illuminate\View\View |
72
|
|
|
*/ |
73
|
|
|
public function show(Game $game) |
74
|
|
|
{ |
75
|
|
|
return view('admin.games.view', compact('game')); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Show the form for editing the specified resource. |
80
|
|
|
* |
81
|
|
|
* @param \Gameap\Models\Game $game |
82
|
|
|
* @return \Illuminate\View\View |
83
|
|
|
*/ |
84
|
|
|
public function edit(Game $game) |
85
|
|
|
{ |
86
|
|
|
return view('admin.games.edit', compact('game')); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Update the specified resource in storage. |
91
|
|
|
* |
92
|
|
|
* @param \Gameap\Http\Requests\GameRequest $request |
93
|
|
|
* @param \Gameap\Models\Game $game |
94
|
|
|
* @return \Illuminate\Http\RedirectResponse |
95
|
|
|
*/ |
96
|
|
|
public function update(GameRequest $request, Game $game) |
97
|
|
|
{ |
98
|
|
|
$game->update($request->all()); |
99
|
|
|
|
100
|
|
|
return redirect()->route('admin.games.index') |
101
|
|
|
->with('success', __('games.update_success_msg')); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Upgrade games and game mods from GameAP Repository |
106
|
|
|
* |
107
|
|
|
*/ |
108
|
|
|
public function upgrade() |
109
|
|
|
{ |
110
|
|
|
$result = $this->repository->upgradeFromRepo(); |
111
|
|
|
|
112
|
|
|
if ($result) { |
|
|
|
|
113
|
|
|
return redirect()->route('admin.games.index') |
114
|
|
|
->with('success', __('games.upgrade_success_msg')); |
115
|
|
|
} else { |
116
|
|
|
return redirect()->route('admin.games.index') |
117
|
|
|
->with('error', __('games.upgrade_fail_msg')); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Remove the specified resource from storage. |
123
|
|
|
* |
124
|
|
|
* @param \Gameap\Models\Game $game |
125
|
|
|
* @return \Illuminate\Http\RedirectResponse |
126
|
|
|
*/ |
127
|
|
|
public function destroy(Game $game) |
128
|
|
|
{ |
129
|
|
|
$game->delete(); |
130
|
|
|
return redirect()->route('admin.games.index') |
131
|
|
|
->with('success', __('games.delete_success_msg')); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|