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\GameModRepository; |
8
|
|
|
use Gameap\Models\GameMod; |
9
|
|
|
use Gameap\Http\Requests\Admin\GameModRequest; |
10
|
|
|
use Illuminate\Contracts\View\Factory; |
11
|
|
|
use Illuminate\Http\RedirectResponse; |
12
|
|
|
use Illuminate\View\View; |
13
|
|
|
|
14
|
|
|
class GameModsController extends AuthController |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The GameRepository instance. |
18
|
|
|
* |
19
|
|
|
* @var GameModRepository |
20
|
|
|
*/ |
21
|
|
|
protected $repository; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Create a new GameController instance. |
25
|
|
|
* |
26
|
|
|
* @param GameModRepository $repository |
27
|
|
|
*/ |
28
|
9 |
|
public function __construct(GameModRepository $repository) |
29
|
|
|
{ |
30
|
9 |
|
$this->repository = $repository; |
31
|
|
|
|
32
|
9 |
|
parent::__construct(); |
33
|
9 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Display new create game mod page |
37
|
|
|
* |
38
|
|
|
* @param string|null |
39
|
|
|
* @return Factory|View |
40
|
|
|
*/ |
41
|
3 |
|
public function create($game = null) |
42
|
|
|
{ |
43
|
3 |
|
return view('admin.game_mods.create', [ |
44
|
3 |
|
'game' => $game, |
45
|
3 |
|
'gameList' => Game::all()->pluck('name', 'code'), |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Store a newly created game mod in storage. |
51
|
|
|
* |
52
|
|
|
* @param GameModRequest $request |
53
|
|
|
* @return RedirectResponse |
54
|
|
|
*/ |
55
|
3 |
|
public function store(GameModRequest $request) |
56
|
|
|
{ |
57
|
3 |
|
GameMod::create($request->all()); |
58
|
|
|
|
59
|
3 |
|
return redirect()->route('admin.games.index') |
60
|
3 |
|
->with('success', __('games.mod_create_success_msg')); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Show the form for editing the specified resource. |
65
|
|
|
* |
66
|
|
|
* @param GameMod $gameMod |
67
|
|
|
* @return View |
68
|
|
|
*/ |
69
|
3 |
|
public function edit(GameMod $gameMod) |
70
|
|
|
{ |
71
|
3 |
|
return view('admin.game_mods.edit', compact('gameMod')); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Update the specified resource in storage. |
76
|
|
|
* |
77
|
|
|
* @param GameModRequest $request |
78
|
|
|
* @param GameMod $gameMod |
79
|
|
|
* @return RedirectResponse |
80
|
|
|
*/ |
81
|
3 |
|
public function update(GameModRequest $request, GameMod $gameMod) |
82
|
|
|
{ |
83
|
3 |
|
$gameMod->update($request->all()); |
84
|
|
|
|
85
|
3 |
|
return redirect()->route('admin.games.edit', ['game' => $gameMod->game_code]) |
86
|
3 |
|
->with('success', __('games.mod_update_success_msg')); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Remove the specified resource from storage. |
91
|
|
|
* |
92
|
|
|
* @param GameMod $gameMod |
93
|
|
|
* @return RedirectResponse |
94
|
|
|
* |
95
|
|
|
* @throws \Exception |
96
|
|
|
*/ |
97
|
3 |
|
public function destroy(GameMod $gameMod) |
98
|
|
|
{ |
99
|
3 |
|
$gameMod->delete(); |
100
|
3 |
|
return redirect()->route('admin.games.index') |
101
|
3 |
|
->with('success', __('games.mod_delete_success_msg')); |
102
|
|
|
} |
103
|
|
|
} |