1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SaasReady\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\JsonResponse; |
6
|
|
|
use Illuminate\Routing\Controller; |
7
|
|
|
use SaasReady\Http\Requests\DynamicSetting\DynamicSettingIndexRequest; |
8
|
|
|
use SaasReady\Http\Requests\DynamicSetting\DynamicSettingStoreRequest; |
9
|
|
|
use SaasReady\Http\Requests\DynamicSetting\DynamicSettingUpdateRequest; |
10
|
|
|
use SaasReady\Http\Responses\DynamicSettingResource; |
11
|
|
|
use SaasReady\Models\DynamicSetting; |
|
|
|
|
12
|
|
|
|
13
|
|
|
class DynamicSettingsController extends Controller |
14
|
|
|
{ |
15
|
|
|
public function index(DynamicSettingIndexRequest $request): JsonResponse |
16
|
|
|
{ |
17
|
|
|
$relatedModel = $request->getRelatedModel(); |
18
|
|
|
|
19
|
|
|
$dynamicSettings = DynamicSetting::orderBy('created_at', 'DESC') |
20
|
|
|
->when($relatedModel, fn ($q) => $q->where([ |
21
|
|
|
'model_id' => $relatedModel->getKey(), |
22
|
|
|
'model_type' => $relatedModel->getMorphClass(), |
23
|
|
|
])) |
24
|
|
|
->paginate($request->integer('limit') ?: 10); |
25
|
|
|
|
26
|
|
|
return DynamicSettingResource::collection($dynamicSettings)->response(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function show(DynamicSetting $dynamicSetting): JsonResponse |
30
|
|
|
{ |
31
|
|
|
return (new DynamicSettingResource($dynamicSetting))->response(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function store(DynamicSettingStoreRequest $request): JsonResponse |
35
|
|
|
{ |
36
|
|
|
$relatedModel = $request->getRelatedModel(); |
37
|
|
|
|
38
|
|
|
$dynamicSetting = DynamicSetting::create([ |
39
|
|
|
...$request->validated(), |
40
|
|
|
'model_id' => $relatedModel->getKey(), |
41
|
|
|
'model_type' => $relatedModel->getMorphClass(), |
42
|
|
|
]); |
43
|
|
|
|
44
|
|
|
return new JsonResponse([ |
45
|
|
|
'uuid' => $dynamicSetting->uuid, |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function update( |
50
|
|
|
DynamicSettingUpdateRequest $request, |
51
|
|
|
DynamicSetting $dynamicSetting |
52
|
|
|
): JsonResponse { |
53
|
|
|
$relatedModel = $request->getRelatedModel(); |
54
|
|
|
|
55
|
|
|
$dynamicSetting->update([ |
56
|
|
|
...$request->validated(), |
57
|
|
|
'model_id' => $relatedModel?->getKey() ?? $dynamicSetting->model_id, |
58
|
|
|
'model_type' => $relatedModel?->getMorphClass() ?? $dynamicSetting->model_type, |
59
|
|
|
]); |
60
|
|
|
|
61
|
|
|
return new JsonResponse([ |
62
|
|
|
'uuid' => $dynamicSetting->uuid, |
63
|
|
|
]); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function destroy(DynamicSetting $dynamicSetting): JsonResponse |
67
|
|
|
{ |
68
|
|
|
$dynamicSetting->delete(); |
69
|
|
|
|
70
|
|
|
return new JsonResponse(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
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