PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Modules / Shipping / Http / Controllers / ShippingMethodController.php

ShippingMethodController.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Modules/Shipping/Http/Controllers/ShippingMethodController.php

49 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Modules\Shipping\Http\Controllers;
4
5 use FluentCart\App\Http\Controllers\Controller;
6 use FluentCart\App\Models\ShippingMethod;
7 use FluentCart\Framework\Support\Arr;
8 use FluentCart\App\Modules\Shipping\Http\Requests\ShippingMethodRequest;
9
10 class ShippingMethodController extends Controller
11 {
12
13 public function store(ShippingMethodRequest $request): \WP_REST_Response
14 {
15 $data = $request->getSafe($request->sanitize());
16
17 ShippingMethod::create($data);
18
19 return $this->sendSuccess([
20 'message' => __('Shipping method has been created successfully', 'fluent-cart')
21 ]);
22 }
23
24 public function update(ShippingMethodRequest $request): \WP_REST_Response
25 {
26 $data = $request->getSafe($request->sanitize());
27 $methodId = Arr::get($data, 'method_id');
28
29 $method = ShippingMethod::findOrFail($methodId);
30
31 $method->update($data);
32
33 return $this->sendSuccess([
34 'message' => __('Shipping method has been updated successfully', 'fluent-cart')
35 ]);
36 }
37
38 public function destroy($method_id)
39 {
40 $method = ShippingMethod::findOrFail($method_id);
41 $method->delete();
42
43 return $this->sendSuccess([
44 'message' => __('Shipping method has been deleted successfully', 'fluent-cart')
45 ]);
46 }
47
48 }
49