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 / api / Resource / ActivityResource.php

ActivityResource.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at api/Resource/ActivityResource.php

60 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\Api\Resource;
4
5 use FluentCart\Framework\Database\Orm\Builder;
6 use FluentCart\App\Models\Activity;
7 use FluentCart\Framework\Support\Arr;
8
9 class ActivityResource extends BaseResourceApi
10 {
11 public static function get(array $params = [])
12 {
13 $logsQuery = Activity::query()
14 ->orderBy(
15 sanitize_sql_orderby(Arr::get($params, 'order_by', 'id')),
16 sanitize_sql_orderby(Arr::get($params, 'order_type', 'DESC'))
17 );
18 $status = Arr::get($params, 'status');
19
20 if (!empty($status) && $status !== 'all') {
21 if ($status === 'api') {
22 $logsQuery->where('log_type', 'api');
23 } else {
24 $logsQuery->where('status', $status);
25 }
26 }
27
28 return $logsQuery->paginate(
29 Arr::get($params, 'per_page', 15),
30 ['*'],
31 'page',
32 Arr::get($params, 'page', 1)
33 );
34 }
35
36 public static function find($id, $params = [])
37 {
38 return Activity::query()->find($id);
39 }
40
41 public static function create($data, $params = [])
42 {
43 return Activity::query()->create($data);
44 }
45
46 public static function update($data, $id, $params = [])
47 {
48 return Activity::query()->where('id', $id)->update($data);
49 }
50
51 public static function delete($id, $params = [])
52 {
53 return Activity::query()->where('id', $id)->delete();
54 }
55
56 static function getQuery(): Builder
57 {
58 return Activity::query();
59 }
60 }