|
|
@@ -17,7 +17,6 @@ use App\Http\Requests\Purchase\StorePurchaseRequest;
|
|
17
|
17
|
use App\Http\Requests\Purchase\UpdatePurchaseRequest;
|
|
18
|
18
|
use App\Models\Company;
|
|
19
|
19
|
use App\Models\User;
|
|
20
|
|
-use App\Policies\PurchasePolicy;
|
|
21
|
20
|
use App\Services\FunctionService;
|
|
22
|
21
|
use App\Services\PurchaseService;
|
|
23
|
22
|
|
|
|
@@ -244,21 +243,17 @@ class PurchaseController extends Controller
|
|
244
|
243
|
];
|
|
245
|
244
|
|
|
246
|
245
|
if (!empty($product["label"])) {
|
|
247
|
|
- if ($product["label"] == "add") {
|
|
248
|
|
- $purchase->purchaseDetail()->create($validated);
|
|
249
|
|
- }
|
|
250
|
|
-
|
|
251
|
|
- if ($product["label"] == "edit") {
|
|
252
|
|
- $purchase->purchaseDetail
|
|
|
246
|
+ match ($product["label"]) {
|
|
|
247
|
+ "add" => $purchase
|
|
|
248
|
+ ->purchaseDetail()
|
|
|
249
|
+ ->create($validated),
|
|
|
250
|
+ "edit" => $purchase->purchaseDetail
|
|
253
|
251
|
->find($product["id"])
|
|
254
|
|
- ->update($validated);
|
|
255
|
|
- }
|
|
256
|
|
-
|
|
257
|
|
- if ($product["label"] == "delete") {
|
|
258
|
|
- $purchase->purchaseDetail
|
|
|
252
|
+ ->update($validated),
|
|
|
253
|
+ "delete" => $purchase->purchaseDetail
|
|
259
|
254
|
->find($product["id"])
|
|
260
|
|
- ->delete();
|
|
261
|
|
- }
|
|
|
255
|
+ ->delete(),
|
|
|
256
|
+ };
|
|
262
|
257
|
}
|
|
263
|
258
|
|
|
264
|
259
|
if ($request->status == "success") {
|