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 / Http / Controllers / ActivityController.php

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

54 lines 1.5 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\Api\Resource\ActivityResource;
6 use FluentCart\Framework\Http\Request\Request;
7 use FluentCart\App\Services\Filter\LogFilter;
8
9 class ActivityController extends Controller
10 {
11 public function index(Request $request)
12 {
13 return $this->sendSuccess([
14 'activities' => LogFilter::fromRequest($request)
15 ->paginate()
16 ]);
17 }
18 public function delete($id)
19 {
20 $response = ActivityResource::delete($id);
21 if (is_wp_error($response)) {
22 return $this->sendError([
23 'message'=> $response->get_error_message()
24 ]);
25 }
26 return $this->sendSuccess([
27 'message' => __('Activity Deleted Successfully', 'fluent-cart')
28 ]);
29 }
30
31 public function markReadUnread($id, Request $request): \WP_REST_Response
32 {
33 $status = $request->getSafe('status', 'sanitize_text_field');
34
35 $response = ActivityResource::update(['read_status' => $status], $id);
36 if (is_wp_error($response)) {
37 return $this->sendError([
38 'message'=> $response->get_error_message()
39 ]);
40 }
41 if ($status === 'read'){
42 return $this->sendSuccess([
43 'message' => __('Activity Marked as Read', 'fluent-cart')
44 ]);
45 }else{
46 return $this->sendSuccess([
47 'message' => __('Activity Marked as Unread', 'fluent-cart')
48 ]);
49 }
50
51 }
52
53 }
54