|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests\SoundRequest; |
|
6
|
|
|
use App\Services\SoundServices; |
|
7
|
|
|
use Illuminate\Http\Request; |
|
8
|
|
|
use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger; |
|
9
|
|
|
|
|
10
|
|
|
class SoundsController extends Controller |
|
11
|
|
|
{ |
|
12
|
|
|
use ActivityLogger; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Create a new controller instance. |
|
16
|
|
|
* |
|
17
|
|
|
* @return void |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->middleware('auth'); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Display a listing of the resource. |
|
26
|
|
|
* |
|
27
|
|
|
* @return \Illuminate\Http\Response |
|
28
|
|
|
*/ |
|
29
|
|
|
public function index() |
|
30
|
|
|
{ |
|
31
|
|
|
$sounds = SoundServices::getSortedSounds(); |
|
32
|
|
|
$enabledSounds = SoundServices::getEnabledSortedSounds(); |
|
33
|
|
|
|
|
34
|
|
|
$data = [ |
|
35
|
|
|
'sounds' => $sounds, |
|
36
|
|
|
'enabledSounds' => $enabledSounds, |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
return view('pages.sounds.index', $data); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Show the form for creating a new resource. |
|
44
|
|
|
* |
|
45
|
|
|
* @return \Illuminate\Http\Response |
|
46
|
|
|
*/ |
|
47
|
|
|
public function create() |
|
48
|
|
|
{ |
|
49
|
|
|
$sound = SoundServices::getBlankSound(); |
|
50
|
|
|
|
|
51
|
|
|
return view('pages.sounds.create', ['sound' => $sound]); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Create Recording Page |
|
56
|
|
|
* |
|
57
|
|
|
* @return \Illuminate\Http\Response |
|
58
|
|
|
*/ |
|
59
|
|
|
public function createRecording() |
|
60
|
|
|
{ |
|
61
|
|
|
return view('pages.sounds.record-sound'); |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Store a newly created resource in storage. |
|
66
|
|
|
* |
|
67
|
|
|
* @param \App\Http\Requests\SoundRequest $request |
|
68
|
|
|
* |
|
69
|
|
|
* @return \Illuminate\Http\Response |
|
70
|
|
|
*/ |
|
71
|
|
|
public function store(SoundRequest $request) |
|
72
|
|
|
{ |
|
73
|
|
|
$validated = $request->validated(); |
|
74
|
|
|
$sound = SoundServices::storeNewSound($validated); |
|
75
|
|
|
|
|
76
|
|
|
ActivityLogger::activity('New sound created: '.$sound); |
|
77
|
|
|
|
|
78
|
|
|
return redirect('sounds') |
|
|
|
|
|
|
79
|
|
|
->with('success', 'Sound created: <strong>'.$sound->title.'</strong>'); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Display the specified resource. |
|
84
|
|
|
* |
|
85
|
|
|
* @param int $id |
|
86
|
|
|
* |
|
87
|
|
|
* @return \Illuminate\Http\Response |
|
88
|
|
|
*/ |
|
89
|
|
|
public function show($id) |
|
90
|
|
|
{ |
|
91
|
|
|
$sound = SoundServices::getSound($id); |
|
92
|
|
|
|
|
93
|
|
|
return view('pages.sounds.show', ['sound' => $sound]); |
|
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Show the form for editing the specified resource. |
|
98
|
|
|
* |
|
99
|
|
|
* @param int $id |
|
100
|
|
|
* |
|
101
|
|
|
* @return \Illuminate\Http\Response |
|
102
|
|
|
*/ |
|
103
|
|
|
public function edit($id) |
|
104
|
|
|
{ |
|
105
|
|
|
$sound = SoundServices::getSound($id); |
|
106
|
|
|
|
|
107
|
|
|
return view('pages.sounds.edit', ['sound' => $sound]); |
|
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Update the specified resource in storage. |
|
112
|
|
|
* |
|
113
|
|
|
* @param \App\Http\Requests\SoundRequest $request |
|
114
|
|
|
* @param int $id |
|
115
|
|
|
* |
|
116
|
|
|
* @return \Illuminate\Http\Response |
|
117
|
|
|
*/ |
|
118
|
|
|
public function update(SoundRequest $request, $id) |
|
119
|
|
|
{ |
|
120
|
|
|
$validated = $request->validated(); |
|
121
|
|
|
$sound = SoundServices::updateSound(SoundServices::getSound($id), $validated); |
|
122
|
|
|
|
|
123
|
|
|
ActivityLogger::activity('Sounds updated: '.$sound); |
|
124
|
|
|
|
|
125
|
|
|
return redirect() |
|
|
|
|
|
|
126
|
|
|
->back() |
|
127
|
|
|
->with('success', 'Sound updated: <strong>'.$sound->title.'</strong>'); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Remove the specified resource from storage. |
|
132
|
|
|
* |
|
133
|
|
|
* @param int $id |
|
134
|
|
|
* |
|
135
|
|
|
* @return \Illuminate\Http\Response |
|
136
|
|
|
*/ |
|
137
|
|
|
public function destroy($id) |
|
138
|
|
|
{ |
|
139
|
|
|
$sound = SoundServices::deleteSound(SoundServices::getSound($id)); |
|
140
|
|
|
|
|
141
|
|
|
ActivityLogger::activity('Sounds deleted: '.$sound); |
|
142
|
|
|
|
|
143
|
|
|
return redirect('sounds')->with('success', 'Sound deleted <strong>'.$sound->title.'</strong>'); |
|
|
|
|
|
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|