10
10
use App \Repositories \ResponseRepository ;
11
11
use Illuminate \Http \Response ;
12
12
13
+ /**
14
+ * @OA\Info(
15
+ * description="API Documentation - Basic CRUD Laravel",
16
+ * version="1.0.0",
17
+ * title="Basic CRUD Laravel API Documentation",
18
+ * @OA\Contact(
19
+
20
+ * ),
21
+ * @OA\License(
22
+ * name="GPL2",
23
+ * url="https://devsenv.com"
24
+ * )
25
+ * )
26
+ */
27
+
13
28
class ProductsController extends Controller
14
29
{
15
30
public $ productRepository ;
@@ -44,16 +59,15 @@ public function index()
44
59
}
45
60
}
46
61
47
-
48
62
/**
49
63
* @OA\GET(
50
64
* path="/api/products/view/all",
51
65
* tags={"Products"},
52
- * summary="All Products - Publicly Accessable ",
53
- * description="All Products - Publicly Accessable ",
66
+ * summary="All Products - Publicly Accessible ",
67
+ * description="All Products - Publicly Accessible ",
54
68
* operationId="indexAll",
55
69
* @OA\Parameter(name="perPage", description="perPage, eg; 20", example=20, in="query", @OA\Schema(type="integer")),
56
- * @OA\Response(response=200, description="All Products - Publicly Accessable " ),
70
+ * @OA\Response(response=200, description="All Products - Publicly Accessible " ),
57
71
* @OA\Response(response=400, description="Bad request"),
58
72
* @OA\Response(response=404, description="Resource Not Found"),
59
73
* )
@@ -67,17 +81,17 @@ public function indexAll(Request $request)
67
81
return $ this ->responseRepository ->ResponseError (null , $ e ->getMessage (), Response::HTTP_INTERNAL_SERVER_ERROR );
68
82
}
69
83
}
70
-
84
+
71
85
/**
72
86
* @OA\GET(
73
87
* path="/api/products/view/search",
74
88
* tags={"Products"},
75
- * summary="All Products - Publicly Accessable ",
76
- * description="All Products - Publicly Accessable ",
89
+ * summary="All Products - Publicly Accessible ",
90
+ * description="All Products - Publicly Accessible ",
77
91
* operationId="search",
78
92
* @OA\Parameter(name="perPage", description="perPage, eg; 20", example=20, in="query", @OA\Schema(type="integer")),
79
93
* @OA\Parameter(name="search", description="search, eg; Test", example="Test", in="query", @OA\Schema(type="string")),
80
- * @OA\Response(response=200, description="All Products - Publicly Accessable " ),
94
+ * @OA\Response(response=200, description="All Products - Publicly Accessible " ),
81
95
* @OA\Response(response=400, description="Bad request"),
82
96
* @OA\Response(response=404, description="Resource Not Found"),
83
97
* )
@@ -141,7 +155,7 @@ public function show($id)
141
155
{
142
156
try {
143
157
$ data = $ this ->productRepository ->getByID ($ id );
144
- if (is_null ($ data ))
158
+ if (is_null ($ data ))
145
159
return $ this ->responseRepository ->ResponseError (null , 'Product Not Found ' , Response::HTTP_NOT_FOUND );
146
160
147
161
return $ this ->responseRepository ->ResponseSuccess ($ data , 'Product Details Fetch Successfully ! ' );
@@ -176,7 +190,7 @@ public function update(ProductRequest $request, $id)
176
190
{
177
191
try {
178
192
$ data = $ this ->productRepository ->update ($ id , $ request ->all ());
179
- if (is_null ($ data ))
193
+ if (is_null ($ data ))
180
194
return $ this ->responseRepository ->ResponseError (null , 'Product Not Found ' , Response::HTTP_NOT_FOUND );
181
195
182
196
return $ this ->responseRepository ->ResponseSuccess ($ data , 'Product Updated Successfully ! ' );
@@ -201,12 +215,13 @@ public function update(ProductRequest $request, $id)
201
215
public function destroy ($ id )
202
216
{
203
217
try {
204
- $ produtData = $ this ->productRepository ->getByID ($ id );
218
+ $ product = $ this ->productRepository ->getByID ($ id );
205
219
$ deleted = $ this ->productRepository ->delete ($ id );
206
- if (!$ deleted )
220
+ if (!$ deleted ) {
207
221
return $ this ->responseRepository ->ResponseError (null , 'Product Not Found ' , Response::HTTP_NOT_FOUND );
222
+ }
208
223
209
- return $ this ->responseRepository ->ResponseSuccess ($ produtData , 'Product Deleted Successfully ! ' );
224
+ return $ this ->responseRepository ->ResponseSuccess ($ product , 'Product Deleted Successfully ! ' );
210
225
} catch (\Exception $ e ) {
211
226
return $ this ->responseRepository ->ResponseError (null , $ e ->getMessage (), Response::HTTP_INTERNAL_SERVER_ERROR );
212
227
}
0 commit comments