1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SaasReady\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\JsonResponse; |
|
|
|
|
6
|
|
|
use Illuminate\Routing\Controller; |
|
|
|
|
7
|
|
|
use Illuminate\Support\Facades\Event; |
|
|
|
|
8
|
|
|
use SaasReady\Events\Translation\TranslationCreated; |
9
|
|
|
use SaasReady\Events\Translation\TranslationDeleted; |
10
|
|
|
use SaasReady\Events\Translation\TranslationUpdated; |
11
|
|
|
use SaasReady\Http\Requests\Translation\TranslationDestroyRequest; |
12
|
|
|
use SaasReady\Http\Requests\Translation\TranslationIndexRequest; |
13
|
|
|
use SaasReady\Http\Requests\Translation\TranslationShowRequest; |
14
|
|
|
use SaasReady\Http\Requests\Translation\TranslationStoreRequest; |
15
|
|
|
use SaasReady\Http\Requests\Translation\TranslationUpdateRequest; |
16
|
|
|
use SaasReady\Http\Responses\TranslationResource; |
17
|
|
|
use SaasReady\Models\Translation; |
|
|
|
|
18
|
|
|
|
19
|
|
|
class TranslationController extends Controller |
20
|
|
|
{ |
21
|
|
|
public function index(TranslationIndexRequest $request): JsonResponse |
22
|
|
|
{ |
23
|
|
|
$translations = Translation::query() |
24
|
|
|
->when($request->getSearchKeyword(), fn ($q) => $q->filterByKeyword($request->getSearchKeyword())) |
25
|
|
|
->paginate($request->getLimit()); |
26
|
|
|
|
27
|
|
|
return TranslationResource::collection($translations) |
28
|
|
|
->toResponse($request); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function show(TranslationShowRequest $request, Translation $translation): JsonResponse |
32
|
|
|
{ |
33
|
|
|
return (new TranslationResource($translation))->toResponse($request); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function store(TranslationStoreRequest $request): JsonResponse |
37
|
|
|
{ |
38
|
|
|
$translation = Translation::create($request->validated()); |
39
|
|
|
|
40
|
|
|
Event::dispatch(new TranslationCreated($translation)); |
41
|
|
|
|
42
|
|
|
return new JsonResponse([ |
43
|
|
|
'uuid' => $translation->uuid, |
44
|
|
|
], 201); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function update(TranslationUpdateRequest $request, Translation $translation): JsonResponse |
48
|
|
|
{ |
49
|
|
|
$translation->update($request->validated()); |
50
|
|
|
|
51
|
|
|
Event::dispatch(new TranslationUpdated($translation)); |
52
|
|
|
|
53
|
|
|
return new JsonResponse([ |
54
|
|
|
'uuid' => $translation->uuid, |
55
|
|
|
]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function destroy(TranslationDestroyRequest $request, Translation $translation): JsonResponse |
59
|
|
|
{ |
60
|
|
|
$translation->delete(); |
61
|
|
|
|
62
|
|
|
Event::dispatch(new TranslationDeleted($translation)); |
63
|
|
|
|
64
|
|
|
return new JsonResponse(); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
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