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 / FrontendResource / OrderDownloadPermissionResource.php

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

121 lines 4.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\Api\Resource\FrontendResource;
4
5 use FluentCart\Api\Resource\BaseResourceApi;
6 use FluentCart\App\Models\OrderDownloadPermission;
7 use FluentCart\Framework\Database\Orm\Builder;
8 use FluentCart\Framework\Support\Arr;
9
10 class OrderDownloadPermissionResource extends BaseResourceApi
11 {
12
13 public static function getQuery(): Builder
14 {
15 return OrderDownloadPermission::query();
16 }
17
18 /**
19 * Get Order Download Permission based on specified parameters.
20 *
21 * @param array $params Array containing the necessary parameters.
22 *
23 */
24 public static function get(array $params = [])
25 {
26 //
27 }
28
29 /**
30 * Find Order Download Permission by ID.
31 *
32 * @param int $id Required. The ID of Order Download Permission.
33 * @param array $params Optional. Additional parameters for finding a download permission.
34 * [
35 * 'with' => (array) Optional. Relationships name to be eager loaded,
36 * ]
37 *
38 */
39 public static function find($id, $params = [])
40 {
41 $orderId = Arr::get($params, 'order_id', null);
42 $variationId = Arr::get($params, 'variation_id', null);
43 $with = Arr::get($params, 'with', []);
44 return static::getQuery()->with($with)->where('order_id', $orderId)->where('download_id', $id)->where('variation_id', $variationId)->first();
45 }
46
47 /**
48 * Create a new Order Download Permission with the given data
49 *
50 * @param array $data Required. Array containing the necessary parameters
51 * [
52 * 'order_id' => (int) Required. The id of the order,
53 * 'customer_id' => (int) Required. The id of the customer,
54 * 'download_id' => (int) Required. The id of the download file,
55 * 'download_count' => (int) Required. The count of the download log,
56 * 'download_limit' => (int) Required. The limit of the download file,
57 * 'access_expires' => (date) Required. The expiry code of the download file,
58 * ]
59 * @param array $params Optional. Additional parameters for creating a Order Download Permission.
60 *
61 */
62 public static function create($data, $params = [])
63 {
64 $isCreated = static::getQuery()->create($data);
65
66 if ($isCreated) {
67 return static::makeSuccessResponse(
68 $isCreated,
69 __('Download log created successfully!', 'fluent-cart')
70 );
71 }
72
73 return static::makeErrorResponse([
74 [ 'code' => 400, 'message' => __('Download log creation failed.', 'fluent-cart') ]
75 ]);
76 }
77
78 /**
79 * Update Order Download Permission with the given data
80 *
81 * @param array $data Required. Array containing the necessary parameters
82 * [
83 * 'order_id' => (int) Required. The id of the order,
84 * 'customer_id' => (int) Required. The id of the customer,
85 * 'download_id' => (int) Required. The id of the download file,
86 * 'download_count' => (int) Required. The count of the download log,
87 * 'download_limit' => (int) Required. The limit of the download file,
88 * 'access_expires' => (date) Required. The expiry code of the download file,
89 * ]
90 * @param int $id Required. The ID of the Order Download Permission.
91 * @param array $params Optional. Additional parameters for creating a Order Download Permission.
92 *
93 */
94 public static function update($data, $id, $params = [])
95 {
96 $isUpdated = static::getQuery()->find($id)->update($data);
97
98 if ($isUpdated) {
99 return static::makeSuccessResponse(
100 $isUpdated,
101 __('Download log updated successfully!', 'fluent-cart')
102 );
103 }
104
105 return static::makeErrorResponse([
106 [ 'code' => 400, 'message' => __('Download log update failed.', 'fluent-cart') ]
107 ]);
108 }
109
110 /**
111 * Delete a download permission based on the given ID and parameters.
112 *
113 * @param int $id Optional. The ID of the order download permission.
114 * @param array $params Optional. Additional parameters.
115 *
116 */
117 public static function delete($id, $params = [])
118 {
119 //
120 }
121 }