@@ 7-148 (lines=142) @@ | ||
4 | ||
5 | use Codexshaper\WooCommerce\Traits\QueryBuilderTrait; |
|
6 | ||
7 | class Term extends BaseModel |
|
8 | { |
|
9 | use QueryBuilderTrait; |
|
10 | ||
11 | protected $endpoint; |
|
12 | ||
13 | /** |
|
14 | * Retrieve all Items. |
|
15 | * |
|
16 | * @param int $attribute_id |
|
17 | * @param array $options |
|
18 | * |
|
19 | * @return array |
|
20 | */ |
|
21 | protected function all($attribute_id, $options = []) |
|
22 | { |
|
23 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
24 | ||
25 | return self::all($options); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * Retrieve single Item. |
|
30 | * |
|
31 | * @param int $attribute_id |
|
32 | * @param int $id |
|
33 | * @param array $options |
|
34 | * |
|
35 | * @return object |
|
36 | */ |
|
37 | protected function find($attribute_id, $id, $options = []) |
|
38 | { |
|
39 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
40 | ||
41 | return self::find($id, $options); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Create new Item. |
|
46 | * |
|
47 | * @param int $attribute_id |
|
48 | * @param array $data |
|
49 | * |
|
50 | * @return object |
|
51 | */ |
|
52 | protected function create($attribute_id, $data) |
|
53 | { |
|
54 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
55 | ||
56 | return self::create($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Update Existing Item. |
|
61 | * |
|
62 | * @param int $attribute_id |
|
63 | * @param int $id |
|
64 | * @param array $data |
|
65 | * |
|
66 | * @return object |
|
67 | */ |
|
68 | protected function update($attribute_id, $id, $data) |
|
69 | { |
|
70 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
71 | ||
72 | return self::update($id, $data); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * Destroy Item. |
|
77 | * |
|
78 | * @param int $attribute_id |
|
79 | * @param int $id |
|
80 | * @param array $options |
|
81 | * |
|
82 | * @return object |
|
83 | */ |
|
84 | protected function delete($attribute_id, $id, $options = []) |
|
85 | { |
|
86 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
87 | ||
88 | return self::delete($id, $options); |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * Batch Update. |
|
93 | * |
|
94 | * @param int $attribute_id |
|
95 | * @param array $data |
|
96 | * |
|
97 | * @return object |
|
98 | */ |
|
99 | protected function batch($attribute_id, $data) |
|
100 | { |
|
101 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
102 | ||
103 | return self::batch($data); |
|
104 | } |
|
105 | ||
106 | /** |
|
107 | * Paginate results. |
|
108 | * |
|
109 | * @param int $per_page |
|
110 | * @param int $current_page |
|
111 | * |
|
112 | * @return array |
|
113 | */ |
|
114 | protected function paginate( |
|
115 | $attribute_id, |
|
116 | $per_page = 10, |
|
117 | $current_page = 1, |
|
118 | $options = [] |
|
119 | ) { |
|
120 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
121 | ||
122 | return self::paginate($per_page, $current_page, $options); |
|
123 | } |
|
124 | ||
125 | /** |
|
126 | * Count all results. |
|
127 | * |
|
128 | * @return int |
|
129 | */ |
|
130 | protected function count($attribute_id) |
|
131 | { |
|
132 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
133 | ||
134 | return self::count(); |
|
135 | } |
|
136 | ||
137 | /** |
|
138 | * Store data. |
|
139 | * |
|
140 | * @return array |
|
141 | */ |
|
142 | public function save($attribute_id) |
|
143 | { |
|
144 | $this->endpoint = "products/attributes/{$attribute_id}/terms"; |
|
145 | ||
146 | return self::save(); |
|
147 | } |
|
148 | } |
|
149 |
@@ 7-148 (lines=142) @@ | ||
4 | ||
5 | use Codexshaper\WooCommerce\Traits\QueryBuilderTrait; |
|
6 | ||
7 | class Variation extends BaseModel |
|
8 | { |
|
9 | use QueryBuilderTrait; |
|
10 | ||
11 | protected $endpoint; |
|
12 | ||
13 | /** |
|
14 | * Retrieve all Items. |
|
15 | * |
|
16 | * @param int $product_id |
|
17 | * @param array $options |
|
18 | * |
|
19 | * @return array |
|
20 | */ |
|
21 | protected function all($product_id, $options = []) |
|
22 | { |
|
23 | $this->endpoint = "products/{$product_id}/variations"; |
|
24 | ||
25 | return self::all($options); |
|
26 | } |
|
27 | ||
28 | /** |
|
29 | * Retrieve single Item. |
|
30 | * |
|
31 | * @param int $product_id |
|
32 | * @param int $id |
|
33 | * @param array $options |
|
34 | * |
|
35 | * @return object |
|
36 | */ |
|
37 | protected function find($product_id, $id, $options = []) |
|
38 | { |
|
39 | $this->endpoint = "products/{$product_id}/variations"; |
|
40 | ||
41 | return self::find($id, $options); |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Create new Item. |
|
46 | * |
|
47 | * @param int $product_id |
|
48 | * @param array $data |
|
49 | * |
|
50 | * @return object |
|
51 | */ |
|
52 | protected function create($product_id, $data) |
|
53 | { |
|
54 | $this->endpoint = "products/{$product_id}/variations"; |
|
55 | ||
56 | return self::create($data); |
|
57 | } |
|
58 | ||
59 | /** |
|
60 | * Update Existing Item. |
|
61 | * |
|
62 | * @param int $product_id |
|
63 | * @param int $id |
|
64 | * @param array $data |
|
65 | * |
|
66 | * @return object |
|
67 | */ |
|
68 | protected function update($product_id, $id, $data) |
|
69 | { |
|
70 | $this->endpoint = "products/{$product_id}/variations"; |
|
71 | ||
72 | return self::update($id, $data); |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * Destroy Item. |
|
77 | * |
|
78 | * @param int $product_id |
|
79 | * @param int $id |
|
80 | * @param array $options |
|
81 | * |
|
82 | * @return object |
|
83 | */ |
|
84 | protected function delete($product_id, $id, $options = []) |
|
85 | { |
|
86 | $this->endpoint = "products/{$product_id}/variations"; |
|
87 | ||
88 | return self::delete($id, $options); |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * Batch Update. |
|
93 | * |
|
94 | * @param int $product_id |
|
95 | * @param array $data |
|
96 | * |
|
97 | * @return object |
|
98 | */ |
|
99 | protected function batch($product_id, $data) |
|
100 | { |
|
101 | $this->endpoint = "products/{$product_id}/variations"; |
|
102 | ||
103 | return self::batch($data); |
|
104 | } |
|
105 | ||
106 | /** |
|
107 | * Paginate results. |
|
108 | * |
|
109 | * @param int $per_page |
|
110 | * @param int $current_page |
|
111 | * |
|
112 | * @return array |
|
113 | */ |
|
114 | protected function paginate( |
|
115 | $product_id, |
|
116 | $per_page = 10, |
|
117 | $current_page = 1, |
|
118 | $options = [] |
|
119 | ) { |
|
120 | $this->endpoint = "products/{$product_id}/variations"; |
|
121 | ||
122 | return self::paginate($per_page, $current_page, $options); |
|
123 | } |
|
124 | ||
125 | /** |
|
126 | * Count all results. |
|
127 | * |
|
128 | * @return int |
|
129 | */ |
|
130 | protected function count($product_id) |
|
131 | { |
|
132 | $this->endpoint = "products/{$product_id}/variations"; |
|
133 | ||
134 | return self::count(); |
|
135 | } |
|
136 | ||
137 | /** |
|
138 | * Store data. |
|
139 | * |
|
140 | * @return array |
|
141 | */ |
|
142 | public function save($product_id) |
|
143 | { |
|
144 | $this->endpoint = "products/{$product_id}/variations"; |
|
145 | ||
146 | return self::save(); |
|
147 | } |
|
148 | } |
|
149 |