@@ -53,9 +53,9 @@ public function show(Product $product): JsonResponse
53
53
{
54
54
if (!$ this ->canAccess ($ product )) {
55
55
return $ this ->error ([], AuthConstants::PERMISSION );
56
- } else {
57
- return $ this ->success (new ProductResource ($ product ));
58
56
}
57
+
58
+ return $ this ->success (new ProductResource ($ product ));
59
59
}
60
60
61
61
/**
@@ -67,20 +67,20 @@ public function update(ProductRequest $request, Product $product): JsonResponse
67
67
{
68
68
if (!$ this ->canAccess ($ product )) {
69
69
return $ this ->error (AuthConstants::PERMISSION );
70
- } else {
71
- if (isset ($ request ->categories )) {
72
- $ categories = Category::ForUserByIds ($ request ->categories );
73
-
74
- $ product ->categories ()->detach ();
75
- if (!$ categories ->isEmpty ()) {
76
- $ product ->categories ()->attach ($ categories );
77
- }
78
- }
70
+ }
79
71
80
- $ product ->update ($ request ->all ());
72
+ if (isset ($ request ->categories )) {
73
+ $ categories = Category::ForUserByIds ($ request ->categories );
81
74
82
- return $ this ->success (new ProductResource ($ product ), ProductConstants::UPDATE );
75
+ $ product ->categories ()->detach ();
76
+ if (!$ categories ->isEmpty ()) {
77
+ $ product ->categories ()->attach ($ categories );
78
+ }
83
79
}
80
+
81
+ $ product ->update ($ request ->all ());
82
+
83
+ return $ this ->success (new ProductResource ($ product ), ProductConstants::UPDATE );
84
84
}
85
85
86
86
/**
@@ -91,10 +91,10 @@ public function destroy(Product $product): JsonResponse
91
91
{
92
92
if (!$ this ->canAccess ($ product )) {
93
93
return $ this ->error (AuthConstants::PERMISSION );
94
- } else {
95
- $ product ->delete ();
96
-
97
- return $ this ->success ([], ProductConstants::DESTROY );
98
94
}
95
+
96
+ $ product ->delete ();
97
+
98
+ return $ this ->success ([], ProductConstants::DESTROY );
99
99
}
100
100
}
0 commit comments