Issues (64)

app/Http/Controllers/SoundsController.php (9 issues)

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