1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Services; |
4
|
|
|
|
5
|
|
|
use App\Models\Sound; |
6
|
|
|
|
7
|
|
|
class SoundServices |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Get the Sounds from Database. |
11
|
|
|
* |
12
|
|
|
* @param int $id Sound Id |
13
|
|
|
* |
14
|
|
|
* @return Collection The Sound |
|
|
|
|
15
|
|
|
*/ |
16
|
|
|
public static function getSound($id) |
17
|
|
|
{ |
18
|
|
|
if (!$id) { |
19
|
|
|
return abort(404); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
return Sound::findOrFail($id); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public static function getAllSounds() |
26
|
|
|
{ |
27
|
|
|
return Sound::all(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Gets the sorted sounds. |
32
|
|
|
* |
33
|
|
|
* @return collection The sorted sounds. |
|
|
|
|
34
|
|
|
*/ |
35
|
|
|
public static function getSortedSounds() |
36
|
|
|
{ |
37
|
|
|
return Sound::sortedSounds()->get(); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Gets the enabled and sorted sounds. |
42
|
|
|
* |
43
|
|
|
* @return collection The enabled sorted sounds. |
44
|
|
|
*/ |
45
|
|
|
public static function getEnabledSortedSounds() |
46
|
|
|
{ |
47
|
|
|
return Sound::enabledSounds()->sortedSounds()->get(); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Gets the blank sound. |
52
|
|
|
* |
53
|
|
|
* @return Empty Sound Collection. |
|
|
|
|
54
|
|
|
*/ |
55
|
|
|
public static function getBlankSound() |
56
|
|
|
{ |
57
|
|
|
return new Sound; |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Update a sound |
62
|
|
|
* |
63
|
|
|
* @param collection $sound The sound |
64
|
|
|
* @param array $soundData The sound data |
65
|
|
|
* |
66
|
|
|
* @return Collection Sound |
67
|
|
|
*/ |
68
|
|
|
public static function updateSound(Sound $sound, $soundData) |
69
|
|
|
{ |
70
|
|
|
$sound->fill($soundData); |
71
|
|
|
$sound->save(); |
72
|
|
|
|
73
|
|
|
return $sound; |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Update a sound enabled/disabled |
78
|
|
|
* |
79
|
|
|
* @param int $soundId The sound identifier |
80
|
|
|
* @param boolean $status The status |
81
|
|
|
* |
82
|
|
|
* @return collection \App\Models\Sound\Sound $sound |
83
|
|
|
*/ |
84
|
|
|
public static function updateSoundStatus($soundId, $status) |
85
|
|
|
{ |
86
|
|
|
$sound = self::getSound($soundId); |
87
|
|
|
$sound->enabled = $status; |
88
|
|
|
$sound->save(); |
89
|
|
|
|
90
|
|
|
return $sound; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Stores a new sound. |
95
|
|
|
* |
96
|
|
|
* @param array $soundData The sound data |
97
|
|
|
* |
98
|
|
|
* @return collection $newSound The newly stored sound |
99
|
|
|
*/ |
100
|
|
|
public static function storeNewSound($soundData) |
101
|
|
|
{ |
102
|
|
|
$lastSound = collect(Sound::sortedSounds()->get())->last(); |
103
|
|
|
$sort_order = ['sort_order' => $lastSound->sort_order + 1]; |
104
|
|
|
$newSound = Sound::create(array_merge($soundData, $sort_order)); |
105
|
|
|
|
106
|
|
|
return $newSound; |
|
|
|
|
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Delete a sound |
111
|
|
|
* |
112
|
|
|
* @param collection $sound The sound |
113
|
|
|
* |
114
|
|
|
* @return Collection of deleted Sound |
115
|
|
|
*/ |
116
|
|
|
public static function deleteSound(Sound $sound) |
117
|
|
|
{ |
118
|
|
|
$sound->delete(); |
119
|
|
|
|
120
|
|
|
return $sound; |
|
|
|
|
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths