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