|
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\Country\CountryCreated; |
|
9
|
|
|
use SaasReady\Events\Country\CountryDeleted; |
|
10
|
|
|
use SaasReady\Events\Country\CountryUpdated; |
|
11
|
|
|
use SaasReady\Http\Requests\Country\CountryDestroyRequest; |
|
12
|
|
|
use SaasReady\Http\Requests\Country\CountryIndexRequest; |
|
13
|
|
|
use SaasReady\Http\Requests\Country\CountryShowRequest; |
|
14
|
|
|
use SaasReady\Http\Requests\Country\CountryStoreRequest; |
|
15
|
|
|
use SaasReady\Http\Requests\Country\CountryUpdateRequest; |
|
16
|
|
|
use SaasReady\Http\Responses\CountryResource; |
|
17
|
|
|
use SaasReady\Models\Country; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
class CountryController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
public function index(CountryIndexRequest $request): JsonResponse |
|
22
|
|
|
{ |
|
23
|
|
|
$countries = Country::orderBy('name'); |
|
24
|
|
|
|
|
25
|
|
|
return CountryResource::collection( |
|
26
|
|
|
$request->wantsPagination() |
|
27
|
|
|
? $countries->paginate($request->getLimit()) |
|
28
|
|
|
: $countries->get() |
|
29
|
|
|
)->toResponse($request); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function show(CountryShowRequest $request, Country $country): JsonResponse |
|
33
|
|
|
{ |
|
34
|
|
|
return (new CountryResource($country))->toResponse($request); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function store(CountryStoreRequest $request): JsonResponse |
|
38
|
|
|
{ |
|
39
|
|
|
$country = Country::create($request->validated()); |
|
40
|
|
|
|
|
41
|
|
|
Event::dispatch(new CountryCreated($country)); |
|
42
|
|
|
|
|
43
|
|
|
return new JsonResponse([ |
|
44
|
|
|
'uuid' => $country->uuid, |
|
45
|
|
|
], 201); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function update(CountryUpdateRequest $request, Country $country): JsonResponse |
|
49
|
|
|
{ |
|
50
|
|
|
$country->update($request->validated()); |
|
51
|
|
|
|
|
52
|
|
|
Event::dispatch(new CountryUpdated($country)); |
|
53
|
|
|
|
|
54
|
|
|
return new JsonResponse([ |
|
55
|
|
|
'uuid' => $country->uuid, |
|
56
|
|
|
]); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function destroy(CountryDestroyRequest $request, Country $country): JsonResponse |
|
60
|
|
|
{ |
|
61
|
|
|
$country->delete(); |
|
62
|
|
|
|
|
63
|
|
|
Event::dispatch(new CountryDeleted($country)); |
|
64
|
|
|
|
|
65
|
|
|
return new JsonResponse(); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
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