PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.23
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.23
1.6.5 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 All 48 releases
fluent-cart / app / Http / Controllers / TaxController.php

TaxController.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.3.23, at app/Http/Controllers/TaxController.php

43 lines 1.2 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\Http\Controllers;
4
5 use FluentCart\Framework\Support\Arr;
6 use FluentCart\App\Models\OrderTaxRate;
7 use FluentCart\App\Services\Filter\TaxFilter;
8 use FluentCart\App\Services\DateTime\DateTime;
9 use FluentCart\Framework\Http\Request\Request;
10
11 class TaxController extends Controller
12 {
13 public function index(Request $request)
14 {
15 return $this->sendSuccess([
16 'taxes' => TaxFilter::fromRequest($request)->paginate(),
17 ]);
18 }
19
20 public function markAsFiled(Request $request)
21 {
22 $idsToMark = Arr::get($request->getSafe(['ids.*' => 'intval']), 'ids', []);
23
24 if (empty($idsToMark)) {
25 return $this->sendError([
26 'message' => __('No IDs provided to mark!', 'fluent-cart'),
27 ], 400);
28 }
29
30 $result = OrderTaxRate::whereIn('id', $idsToMark)
31 ->whereNull('filed_at')
32 ->update([
33 'filed_at' => DateTime::gmtNow(),
34 ]);
35
36 if (is_wp_error($result)) {
37 return $result;
38 }
39
40 return $this->sendSuccess(['message' => __('Taxes marked as filed successfully', 'fluent-cart')]);
41 }
42 }
43