Completed
Push — master ( f9282d...b5d17f )
by Jeremy
21:36
created

SoundsController::createRecording()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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;
0 ignored issues
show
Bug introduced by
The trait jeremykenedy\LaravelLogg...p\Traits\ActivityLogger requires the property $id which is not provided by App\Http\Controllers\SoundsController.
Loading history...
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);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('pages.sounds.index', $data) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('pages.sound...ray('sound' => $sound)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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');
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('pages.sounds.record-sound') returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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')
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('sounds'...d->title . '</strong>') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('pages.sound...ray('sound' => $sound)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('pages.sound...ray('sound' => $sound)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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()
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->back(...d->title . '</strong>') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
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>');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect('sounds'...d->title . '</strong>') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
144
    }
145
}
146