@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->args = $args; |
28 | 28 | |
29 | - if( Helpers::isMultiArray($args) ) |
|
29 | + if (Helpers::isMultiArray($args)) |
|
30 | 30 | { |
31 | 31 | Throw new InvalidConditionException('Multi dimensional array is not supported.'); |
32 | 32 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function applyConditionWithoutTax($totalOrSubTotalOrPrice) |
129 | 129 | { |
130 | - if(isset($this->getAttributes()['data']['value_ex_tax']) AND $this->args['value']) { |
|
130 | + if (isset($this->getAttributes()['data']['value_ex_tax']) AND $this->args['value']) { |
|
131 | 131 | return $this->apply($totalOrSubTotalOrPrice, $this->getAttributes()['data']['value_ex_tax']); |
132 | 132 | } |
133 | 133 | |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | // has a minus or plus sign so we can decide what to do with the |
174 | 174 | // percentage, whether to add or subtract it to the total/subtotal/price |
175 | 175 | // if we can't find any plus/minus sign, we will assume it as plus sign |
176 | - if( $this->valueIsPercentage($conditionValue) ) |
|
176 | + if ($this->valueIsPercentage($conditionValue)) |
|
177 | 177 | { |
178 | - if( $this->valueIsToBeSubtracted($conditionValue) ) |
|
178 | + if ($this->valueIsToBeSubtracted($conditionValue)) |
|
179 | 179 | { |
180 | - $value = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
|
180 | + $value = Helpers::normalizePrice($this->cleanValue($conditionValue)); |
|
181 | 181 | |
182 | 182 | $this->parsedRawValue = $totalOrSubTotalOrPrice * ($value / 100); |
183 | 183 | |
184 | 184 | $result = floatval($totalOrSubTotalOrPrice - $this->parsedRawValue); |
185 | 185 | } |
186 | - else if ( $this->valueIsToBeAdded($conditionValue) ) |
|
186 | + else if ($this->valueIsToBeAdded($conditionValue)) |
|
187 | 187 | { |
188 | - $value = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
|
188 | + $value = Helpers::normalizePrice($this->cleanValue($conditionValue)); |
|
189 | 189 | |
190 | 190 | $this->parsedRawValue = $totalOrSubTotalOrPrice * ($value / 100); |
191 | 191 | |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | // next is we will check if it has a minus/plus sign so then we can just deduct it to total/subtotal/price |
206 | 206 | else |
207 | 207 | { |
208 | - if( $this->valueIsToBeSubtracted($conditionValue) ) |
|
208 | + if ($this->valueIsToBeSubtracted($conditionValue)) |
|
209 | 209 | { |
210 | - $this->parsedRawValue = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
|
210 | + $this->parsedRawValue = Helpers::normalizePrice($this->cleanValue($conditionValue)); |
|
211 | 211 | |
212 | 212 | $result = floatval($totalOrSubTotalOrPrice - $this->parsedRawValue); |
213 | 213 | } |
214 | - else if ( $this->valueIsToBeAdded($conditionValue) ) |
|
214 | + else if ($this->valueIsToBeAdded($conditionValue)) |
|
215 | 215 | { |
216 | - $this->parsedRawValue = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
|
216 | + $this->parsedRawValue = Helpers::normalizePrice($this->cleanValue($conditionValue)); |
|
217 | 217 | |
218 | 218 | $result = floatval($totalOrSubTotalOrPrice + $this->parsedRawValue); |
219 | 219 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | protected function cleanValue($value) |
272 | 272 | { |
273 | - return str_replace(array('%','-','+'),'',$value); |
|
273 | + return str_replace(array('%', '-', '+'), '', $value); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | if( Helpers::isMultiArray($args) ) |
30 | 30 | { |
31 | 31 | Throw new InvalidConditionException('Multi dimensional array is not supported.'); |
32 | - } |
|
33 | - else |
|
32 | + } else |
|
34 | 33 | { |
35 | 34 | $this->validate($this->args); |
36 | 35 | } |
@@ -182,16 +181,14 @@ discard block |
||
182 | 181 | $this->parsedRawValue = $totalOrSubTotalOrPrice * ($value / 100); |
183 | 182 | |
184 | 183 | $result = floatval($totalOrSubTotalOrPrice - $this->parsedRawValue); |
185 | - } |
|
186 | - else if ( $this->valueIsToBeAdded($conditionValue) ) |
|
184 | + } else if ( $this->valueIsToBeAdded($conditionValue) ) |
|
187 | 185 | { |
188 | 186 | $value = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
189 | 187 | |
190 | 188 | $this->parsedRawValue = $totalOrSubTotalOrPrice * ($value / 100); |
191 | 189 | |
192 | 190 | $result = floatval($totalOrSubTotalOrPrice + $this->parsedRawValue); |
193 | - } |
|
194 | - else |
|
191 | + } else |
|
195 | 192 | { |
196 | 193 | $value = Helpers::normalizePrice($conditionValue); |
197 | 194 | |
@@ -210,14 +207,12 @@ discard block |
||
210 | 207 | $this->parsedRawValue = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
211 | 208 | |
212 | 209 | $result = floatval($totalOrSubTotalOrPrice - $this->parsedRawValue); |
213 | - } |
|
214 | - else if ( $this->valueIsToBeAdded($conditionValue) ) |
|
210 | + } else if ( $this->valueIsToBeAdded($conditionValue) ) |
|
215 | 211 | { |
216 | 212 | $this->parsedRawValue = Helpers::normalizePrice( $this->cleanValue($conditionValue) ); |
217 | 213 | |
218 | 214 | $result = floatval($totalOrSubTotalOrPrice + $this->parsedRawValue); |
219 | - } |
|
220 | - else |
|
215 | + } else |
|
221 | 216 | { |
222 | 217 | $this->parsedRawValue = Helpers::normalizePrice($conditionValue); |
223 | 218 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | protected $config; |
15 | 15 | |
16 | - /** |
|
16 | + /** |
|
17 | 17 | * ItemCollection constructor. |
18 | 18 | * @param array|mixed $items |
19 | 19 | */ |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | $newPrice = 0.00; |
69 | 69 | $processed = 0; |
70 | 70 | |
71 | - if( $this->hasConditions() ) |
|
71 | + if ($this->hasConditions()) |
|
72 | 72 | { |
73 | - if( is_array($this->conditions) ) |
|
73 | + if (is_array($this->conditions)) |
|
74 | 74 | { |
75 | - foreach($this->conditions as $condition) |
|
75 | + foreach ($this->conditions as $condition) |
|
76 | 76 | { |
77 | - if( $condition->getTarget() === 'item' ) |
|
77 | + if ($condition->getTarget() === 'item') |
|
78 | 78 | { |
79 | - ( $processed > 0 ) ? $toBeCalculated = $newPrice : $toBeCalculated = $originalPrice; |
|
79 | + ($processed > 0) ? $toBeCalculated = $newPrice : $toBeCalculated = $originalPrice; |
|
80 | 80 | $newPrice = $condition->applyCondition($toBeCalculated); |
81 | 81 | $processed++; |
82 | 82 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | else |
86 | 86 | { |
87 | - if( $this['conditions']->getTarget() === 'item' ) |
|
87 | + if ($this['conditions']->getTarget() === 'item') |
|
88 | 88 | { |
89 | 89 | $newPrice = $this['conditions']->applyCondition($originalPrice); |
90 | 90 | } |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | $newPrice = 0.00; |
108 | 108 | $processed = 0; |
109 | 109 | |
110 | - if( $this->hasConditions() ) |
|
110 | + if ($this->hasConditions()) |
|
111 | 111 | { |
112 | - if( is_array($this->conditions) ) |
|
112 | + if (is_array($this->conditions)) |
|
113 | 113 | { |
114 | - foreach($this->conditions as $condition) |
|
114 | + foreach ($this->conditions as $condition) |
|
115 | 115 | { |
116 | - if( $condition->getTarget() === 'item' ) |
|
116 | + if ($condition->getTarget() === 'item') |
|
117 | 117 | { |
118 | - ( $processed > 0 ) ? $toBeCalculated = $newPrice : $toBeCalculated = $originalPrice; |
|
118 | + ($processed > 0) ? $toBeCalculated = $newPrice : $toBeCalculated = $originalPrice; |
|
119 | 119 | $newPrice = $condition->applyCondition($toBeCalculated); |
120 | 120 | $processed++; |
121 | 121 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | else |
125 | 125 | { |
126 | - if( $this['conditions']->getTarget() === 'item' ) |
|
126 | + if ($this['conditions']->getTarget() === 'item') |
|
127 | 127 | { |
128 | 128 | $newPrice = $this['conditions']->applyCondition($originalPrice); |
129 | 129 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function __get($name) |
161 | 161 | { |
162 | - if( $this->has($name) ) return $this->get($name); |
|
162 | + if ($this->has($name)) return $this->get($name); |
|
163 | 163 | return null; |
164 | 164 | } |
165 | 165 | |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function hasConditions() |
172 | 172 | { |
173 | - if( ! isset($this['conditions']) ) return false; |
|
174 | - if( is_array($this['conditions']) ) |
|
173 | + if (!isset($this['conditions'])) return false; |
|
174 | + if (is_array($this['conditions'])) |
|
175 | 175 | { |
176 | 176 | return count($this['conditions']) > 0; |
177 | 177 | } |
178 | 178 | $conditionInstance = "Hideyo\\Services\\Cart\\CartCondition"; |
179 | - if( $this['conditions'] instanceof $conditionInstance ) return true; |
|
179 | + if ($this['conditions'] instanceof $conditionInstance) return true; |
|
180 | 180 | return false; |
181 | 181 | } |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function getConditions() |
189 | 189 | { |
190 | - if(! $this->hasConditions() ) return []; |
|
190 | + if (!$this->hasConditions()) return []; |
|
191 | 191 | return $this['conditions']; |
192 | 192 | } |
193 | 193 | } |
194 | 194 | \ No newline at end of file |
@@ -81,8 +81,7 @@ discard block |
||
81 | 81 | $processed++; |
82 | 82 | } |
83 | 83 | } |
84 | - } |
|
85 | - else |
|
84 | + } else |
|
86 | 85 | { |
87 | 86 | if( $this['conditions']->getTarget() === 'item' ) |
88 | 87 | { |
@@ -120,8 +119,7 @@ discard block |
||
120 | 119 | $processed++; |
121 | 120 | } |
122 | 121 | } |
123 | - } |
|
124 | - else |
|
122 | + } else |
|
125 | 123 | { |
126 | 124 | if( $this['conditions']->getTarget() === 'item' ) |
127 | 125 | { |
@@ -159,7 +157,9 @@ discard block |
||
159 | 157 | |
160 | 158 | public function __get($name) |
161 | 159 | { |
162 | - if( $this->has($name) ) return $this->get($name); |
|
160 | + if( $this->has($name) ) { |
|
161 | + return $this->get($name); |
|
162 | + } |
|
163 | 163 | return null; |
164 | 164 | } |
165 | 165 | |
@@ -170,13 +170,17 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function hasConditions() |
172 | 172 | { |
173 | - if( ! isset($this['conditions']) ) return false; |
|
173 | + if( ! isset($this['conditions']) ) { |
|
174 | + return false; |
|
175 | + } |
|
174 | 176 | if( is_array($this['conditions']) ) |
175 | 177 | { |
176 | 178 | return count($this['conditions']) > 0; |
177 | 179 | } |
178 | 180 | $conditionInstance = "Hideyo\\Services\\Cart\\CartCondition"; |
179 | - if( $this['conditions'] instanceof $conditionInstance ) return true; |
|
181 | + if( $this['conditions'] instanceof $conditionInstance ) { |
|
182 | + return true; |
|
183 | + } |
|
180 | 184 | return false; |
181 | 185 | } |
182 | 186 | |
@@ -187,7 +191,9 @@ discard block |
||
187 | 191 | */ |
188 | 192 | public function getConditions() |
189 | 193 | { |
190 | - if(! $this->hasConditions() ) return []; |
|
194 | + if(! $this->hasConditions() ) { |
|
195 | + return []; |
|
196 | + } |
|
191 | 197 | return $this['conditions']; |
192 | 198 | } |
193 | 199 | } |
194 | 200 | \ No newline at end of file |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | Cart::update($productId, array( |
78 | - 'quantity' => array( |
|
79 | - 'relative' => false, |
|
80 | - 'value' => $amount |
|
81 | - ), |
|
78 | + 'quantity' => array( |
|
79 | + 'relative' => false, |
|
80 | + 'value' => $amount |
|
81 | + ), |
|
82 | 82 | )); |
83 | 83 | } else { |
84 | 84 | Cart::remove($productId); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | if ($preSaleDiscount['discount_way'] == 'amount') { |
146 | 146 | $discountValue = "-".$preSaleDiscount->value; |
147 | - } elseif ($preSaleDiscount['discount_way'] == 'percent') { |
|
147 | + } elseif ($preSaleDiscount['discount_way'] == 'percent') { |
|
148 | 148 | $discountValue = "-".$preSaleDiscount['value']."%"; |
149 | 149 | } |
150 | 150 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $productArray['reference_code'] = $productCombination->reference_code; |
61 | 61 | } |
62 | 62 | |
63 | - $productArray['product_images'] = $this->product->ajaxProductImages($product, array($leadingAttributeId), $productAttributeId); |
|
63 | + $productArray['product_images'] = $this->product->ajaxProductImages($product, array($leadingAttributeId), $productAttributeId); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | if ($product->amountSeries()->where('active', '=', '1')->count()) { |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $productArray['product_amount_series_range'] = $product->amountSeries()->where('active', '=', '1')->first()->range(); |
69 | 69 | } |
70 | 70 | |
71 | - if($productArray['price_details']['amount'] > 0) { |
|
71 | + if ($productArray['price_details']['amount'] > 0) { |
|
72 | 72 | |
73 | - if($amount >= $productArray['price_details']['amount']) { |
|
73 | + if ($amount >= $productArray['price_details']['amount']) { |
|
74 | 74 | $amount = $productArray['price_details']['amount']; |
75 | 75 | } |
76 | 76 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | Cart::remove($productId); |
85 | 85 | } |
86 | 86 | |
87 | - if(Cart::getConditionsByType('sending_method_country_price')->count()) { |
|
87 | + if (Cart::getConditionsByType('sending_method_country_price')->count()) { |
|
88 | 88 | $this->updateSendingMethodCountryPrice(Cart::getConditionsByType('sending_method_country_price')->first()->getAttributes()['data']['sending_method_country_price_id']); |
89 | 89 | } |
90 | 90 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $productArray['reference_code'] = $productCombination->reference_code; |
125 | 125 | } |
126 | 126 | |
127 | - $productArray['product_images'] = $this->product->ajaxProductImages($product, array($leadingAttributeId, $productAttributeId)); |
|
127 | + $productArray['product_images'] = $this->product->ajaxProductImages($product, array($leadingAttributeId, $productAttributeId)); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $productId = $productArray['id']; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | $discountValue = false; |
137 | 137 | |
138 | - if(session()->get('preSaleDiscount')) { |
|
138 | + if (session()->get('preSaleDiscount')) { |
|
139 | 139 | $preSaleDiscount = session()->get('preSaleDiscount'); |
140 | 140 | |
141 | 141 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if($preSaleDiscount['products']) { |
|
152 | + if ($preSaleDiscount['products']) { |
|
153 | 153 | |
154 | 154 | $productIds = array_column($preSaleDiscount['products'], 'id'); |
155 | 155 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | $discountCondition = array(); |
178 | - if($discountValue) { |
|
178 | + if ($discountValue) { |
|
179 | 179 | |
180 | 180 | $discountCondition = new \Hideyo\Ecommerce\Framework\Services\Cart\CartCondition(array( |
181 | 181 | 'name' => 'Discount', |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | )); |
186 | 186 | } |
187 | 187 | |
188 | - return Cart::add($productId, $productArray, $amount, $discountCondition); |
|
188 | + return Cart::add($productId, $productArray, $amount, $discountCondition); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | return false; |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | if (isset($sendingMethod->id)) { |
199 | 199 | $sendingMethodArray = $sendingMethod->toArray(); |
200 | 200 | $sendingMethodArray['price_details'] = $sendingMethod->getPriceDetails(); |
201 | - if($sendingMethod->relatedPaymentMethodsActive) { |
|
201 | + if ($sendingMethod->relatedPaymentMethodsActive) { |
|
202 | 202 | $sendingMethodArray['related_payment_methods_list'] = $sendingMethod->relatedPaymentMethodsActive->pluck('title', 'id'); |
203 | 203 | } |
204 | 204 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $valueIncTax = $paymentMethodArray['price_details']['original_price_inc_tax']; |
239 | 239 | $shop = ShopService::find(config()->get('app.shop_id')); |
240 | 240 | $value = $valueIncTax; |
241 | - $freeSending = ( $paymentMethodArray['no_price_from'] - Cart::getSubTotalWithTax()); |
|
241 | + $freeSending = ($paymentMethodArray['no_price_from'] - Cart::getSubTotalWithTax()); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | if ($freeSending < 0) { |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $valueExTax = $sendingMethodArray['price_details']['original_price_ex_tax']; |
292 | 292 | $valueIncTax = $sendingMethodArray['price_details']['original_price_inc_tax']; |
293 | 293 | $value = $valueIncTax; |
294 | - $freeSending = ( $sendingMethodArray['no_price_from'] - Cart::getSubTotalWithTax()); |
|
294 | + $freeSending = ($sendingMethodArray['no_price_from'] - Cart::getSubTotalWithTax()); |
|
295 | 295 | |
296 | 296 | if ($freeSending < 0) { |
297 | 297 | $value = 0; |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | $couponData = array(); |
365 | 365 | $discountValue = 0; |
366 | 366 | |
367 | - if($coupon) { |
|
367 | + if ($coupon) { |
|
368 | 368 | |
369 | 369 | $couponData = $coupon->toArray(); |
370 | - if($coupon->type == 'total_price') { |
|
370 | + if ($coupon->type == 'total_price') { |
|
371 | 371 | |
372 | - if($coupon->discount_way == 'total') { |
|
372 | + if ($coupon->discount_way == 'total') { |
|
373 | 373 | $discountValue = $coupon->value; |
374 | 374 | } elseif ($coupon->discount_way == 'percent') { |
375 | 375 | $discountValue = $coupon->value.'%'; |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | self::setCouponCode($discountValue, $couponData, $couponCode); |
379 | 379 | } |
380 | 380 | |
381 | - if($coupon->type == 'product') { |
|
381 | + if ($coupon->type == 'product') { |
|
382 | 382 | |
383 | - if($coupon->products()->count()) { |
|
383 | + if ($coupon->products()->count()) { |
|
384 | 384 | |
385 | 385 | foreach (Cart::getContent() as $row) { |
386 | 386 | |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | $explode = explode('-', $id); |
389 | 389 | $contains = $coupon->products->contains($explode[0]); |
390 | 390 | |
391 | - if($contains) { |
|
391 | + if ($contains) { |
|
392 | 392 | |
393 | - if($coupon->discount_way == 'total') { |
|
393 | + if ($coupon->discount_way == 'total') { |
|
394 | 394 | $discountValue += $coupon->value; |
395 | 395 | } elseif ($coupon->discount_way == 'percent') { |
396 | 396 | $value = $coupon->value / 100; |
@@ -403,17 +403,17 @@ discard block |
||
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | - if($coupon->type == 'product_category') { |
|
406 | + if ($coupon->type == 'product_category') { |
|
407 | 407 | |
408 | - if($coupon->productCategories()->count()) { |
|
408 | + if ($coupon->productCategories()->count()) { |
|
409 | 409 | |
410 | 410 | foreach (Cart::getContent()->sortBy('id') as $row) { |
411 | 411 | |
412 | 412 | $contains = $coupon->productCategories->contains($row['attributes']['product_category_id']); |
413 | 413 | |
414 | - if($contains) { |
|
414 | + if ($contains) { |
|
415 | 415 | |
416 | - if($coupon->discount_way == 'total') { |
|
416 | + if ($coupon->discount_way == 'total') { |
|
417 | 417 | $discountValue += $coupon->value; |
418 | 418 | } elseif ($coupon->discount_way == 'percent') { |
419 | 419 | $value = $coupon->value / 100; |
@@ -427,16 +427,16 @@ discard block |
||
427 | 427 | } |
428 | 428 | } |
429 | 429 | |
430 | - if($coupon->type == 'sending_method') { |
|
430 | + if ($coupon->type == 'sending_method') { |
|
431 | 431 | |
432 | - if($coupon->sendingMethodCountries()->count()) { |
|
432 | + if ($coupon->sendingMethodCountries()->count()) { |
|
433 | 433 | |
434 | 434 | foreach ($coupon->sendingMethodCountries as $country) { |
435 | 435 | |
436 | - if(Cart::getConditionsByType('sending_method_country_price')){ |
|
437 | - if($country->name == Cart::getConditionsByType('sending_method_country_price')->first()->getAttributes()['data']['sending_method_country_price']['name']) { |
|
436 | + if (Cart::getConditionsByType('sending_method_country_price')) { |
|
437 | + if ($country->name == Cart::getConditionsByType('sending_method_country_price')->first()->getAttributes()['data']['sending_method_country_price']['name']) { |
|
438 | 438 | |
439 | - if($coupon->discount_way == 'total') { |
|
439 | + if ($coupon->discount_way == 'total') { |
|
440 | 440 | $discountValue += $coupon->value; |
441 | 441 | } elseif ($coupon->discount_way == 'percent') { |
442 | 442 | $value = $coupon->value / 100; |
@@ -448,15 +448,15 @@ discard block |
||
448 | 448 | |
449 | 449 | self::setCouponCode($discountValue, $couponData, $couponCode); |
450 | 450 | |
451 | - } elseif($coupon->sendingMethods()->count()) { |
|
451 | + } elseif ($coupon->sendingMethods()->count()) { |
|
452 | 452 | |
453 | 453 | foreach ($coupon->sendingMethods as $sendingMethod) { |
454 | 454 | |
455 | - if(Cart::getConditionsByType('sending_cost')){ |
|
455 | + if (Cart::getConditionsByType('sending_cost')) { |
|
456 | 456 | |
457 | - if($sendingMethod->id == Cart::getConditionsByType('sending_cost')->first()->getAttributes()['data']['sending_method']['id']) { |
|
457 | + if ($sendingMethod->id == Cart::getConditionsByType('sending_cost')->first()->getAttributes()['data']['sending_method']['id']) { |
|
458 | 458 | |
459 | - if($coupon->discount_way == 'total') { |
|
459 | + if ($coupon->discount_way == 'total') { |
|
460 | 460 | $discountValue += $coupon->value; |
461 | 461 | } elseif ($coupon->discount_way == 'percent') { |
462 | 462 | $value = $coupon->value / 100; |
@@ -470,17 +470,17 @@ discard block |
||
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | - if($coupon->type == 'payment_method') { |
|
473 | + if ($coupon->type == 'payment_method') { |
|
474 | 474 | |
475 | - if($coupon->paymentMethods()->count()) { |
|
475 | + if ($coupon->paymentMethods()->count()) { |
|
476 | 476 | |
477 | 477 | foreach ($coupon->paymentMethods as $paymentMethod) { |
478 | 478 | |
479 | - if(Cart::getConditionsByType('payment_method')){ |
|
479 | + if (Cart::getConditionsByType('payment_method')) { |
|
480 | 480 | |
481 | - if($paymentMethod->id == Cart::getConditionsByType('payment_method')->first()->getAttributes()['data']['id']) { |
|
481 | + if ($paymentMethod->id == Cart::getConditionsByType('payment_method')->first()->getAttributes()['data']['id']) { |
|
482 | 482 | |
483 | - if($coupon->discount_way == 'total') { |
|
483 | + if ($coupon->discount_way == 'total') { |
|
484 | 484 | $discountValue += $coupon->value; |
485 | 485 | } elseif ($coupon->discount_way == 'percent') { |
486 | 486 | $value = $coupon->value / 100; |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | ); |
533 | 533 | |
534 | 534 | foreach ($replace as $key => $val) { |
535 | - $content = str_replace("[" . $key . "]", $val, $content); |
|
535 | + $content = str_replace("[".$key."]", $val, $content); |
|
536 | 536 | } |
537 | 537 | $content = nl2br($content); |
538 | 538 | return $content; |
@@ -9,24 +9,24 @@ discard block |
||
9 | 9 | |
10 | 10 | class NewsService extends BaseService |
11 | 11 | { |
12 | - public function __construct(NewsRepository $news) |
|
13 | - { |
|
14 | - $this->repo = $news; |
|
15 | - } |
|
12 | + public function __construct(NewsRepository $news) |
|
13 | + { |
|
14 | + $this->repo = $news; |
|
15 | + } |
|
16 | 16 | |
17 | 17 | public function selectByLimitAndOrderBy($shopId, $limit, $orderBy) |
18 | 18 | { |
19 | - return $this->repo->selectByLimitAndOrderBy($shopId, $limit, $orderBy); |
|
19 | + return $this->repo->selectByLimitAndOrderBy($shopId, $limit, $orderBy); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function selectOneBySlug($shopId, $slug) |
23 | 23 | { |
24 | - return $this->repo->selectOneBySlug($shopId, $slug); |
|
24 | + return $this->repo->selectOneBySlug($shopId, $slug); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function selectAllActiveGroupsByShopId($shopId) |
28 | 28 | { |
29 | - return $this->repo->selectAllActiveGroupsByShopId($shopId); |
|
29 | + return $this->repo->selectAllActiveGroupsByShopId($shopId); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function findGroup($groupId) |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | public function selectAllGroups() |
53 | 53 | { |
54 | - return $this->repo->selectAllGroups(); |
|
54 | + return $this->repo->selectAllGroups(); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | protected $table = 'news_image'; |
15 | 15 | |
16 | 16 | // Add the 'avatar' attachment to the fillable array so that it's mass-assignable on this model. |
17 | - protected $fillable = ['news_id', 'file', 'extension', 'size', 'path', 'rank', 'tag', 'modified_by_user_id',]; |
|
17 | + protected $fillable = ['news_id', 'file', 'extension', 'size', 'path', 'rank', 'tag', 'modified_by_user_id', ]; |
|
18 | 18 | |
19 | 19 | public function news() |
20 | 20 | { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | |
295 | 295 | public function selectAllGroups() |
296 | 296 | { |
297 | - return $this->model->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id)->get(); |
|
297 | + return $this->model->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id)->get(); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | public function findGroup($groupId) |
@@ -325,12 +325,12 @@ discard block |
||
325 | 325 | |
326 | 326 | function selectAllByBlogCategoryId($newsCategoryId) |
327 | 327 | { |
328 | - return $this->model->with(array('extraFields' => function ($query) { |
|
329 | - }, 'taxRate', 'newsCategory', 'relatedBlogs' => function ($query) { |
|
328 | + return $this->model->with(array('extraFields' => function ($query) { |
|
329 | + }, 'taxRate', 'newsCategory', 'relatedBlogs' => function ($query) { |
|
330 | 330 | $query->with('newsImages')->orderBy('rank', 'asc'); |
331 | - }, 'newsImages' => function ($query) { |
|
331 | + }, 'newsImages' => function ($query) { |
|
332 | 332 | $query->orderBy('rank', 'asc'); |
333 | - }))->where('active', '=', 1)->where('news_category_id', '=', $newsCategoryId)->get(); |
|
333 | + }))->where('active', '=', 1)->where('news_category_id', '=', $newsCategoryId)->get(); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | function selectOneById($shopId, $slug) |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | |
345 | 345 | function selectAllActiveGroupsByShopId($shopId) |
346 | 346 | { |
347 | - return $this->modelGroup->where('shop_id', '=', $shopId)->where('active', '=', 1)->get(); |
|
347 | + return $this->modelGroup->where('shop_id', '=', $shopId)->where('active', '=', 1)->get(); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | function selectOneGroupByShopIdAndSlug($shopId, $slug) |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | { |
377 | 377 | $dt = Carbon::now('Europe/Amsterdam'); |
378 | 378 | |
379 | - $result = $this->model |
|
380 | - ->where('shop_id', '=', $shopId) |
|
381 | - ->where('published_at', '<=', $dt->toDateString('Y-m-d')); |
|
379 | + $result = $this->model |
|
380 | + ->where('shop_id', '=', $shopId) |
|
381 | + ->where('published_at', '<=', $dt->toDateString('Y-m-d')); |
|
382 | 382 | |
383 | 383 | return array( |
384 | 384 | 'totals' => $result->get()->count(), |
@@ -392,12 +392,12 @@ discard block |
||
392 | 392 | { |
393 | 393 | $dt = Carbon::now('Europe/Amsterdam'); |
394 | 394 | |
395 | - $result = $this->model |
|
396 | - ->where('shop_id', '=', $shopId) |
|
397 | - ->where('published_at', '<=', $dt->toDateString('Y-m-d')) |
|
398 | - ->whereHas('newsGroup', function ($query) use ($newsGroupSlug) { |
|
395 | + $result = $this->model |
|
396 | + ->where('shop_id', '=', $shopId) |
|
397 | + ->where('published_at', '<=', $dt->toDateString('Y-m-d')) |
|
398 | + ->whereHas('newsGroup', function ($query) use ($newsGroupSlug) { |
|
399 | 399 | $query->where('slug', '=', $newsGroupSlug); |
400 | - }); |
|
400 | + }); |
|
401 | 401 | |
402 | 402 | return array( |
403 | 403 | 'totals' => $result->get()->count(), |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | $this->model = $model; |
29 | 29 | $this->modelImage = $modelImage; |
30 | 30 | $this->modelGroup = $modelGroup; |
31 | - $this->storageImagePath = storage_path() .config('hideyo.storage_path'). "/news/"; |
|
32 | - $this->publicImagePath = public_path() .config('hideyo.public_path'). "/news/"; |
|
31 | + $this->storageImagePath = storage_path().config('hideyo.storage_path')."/news/"; |
|
32 | + $this->publicImagePath = public_path().config('hideyo.public_path')."/news/"; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | if ($newsId) { |
53 | - $rules['title'] = 'required|between:4,65|unique:'.$this->model->getTable().',title,'.$newsId; |
|
53 | + $rules['title'] = 'required|between:4,65|unique:'.$this->model->getTable().',title,'.$newsId; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | ); |
70 | 70 | |
71 | 71 | if ($newsGroupId) { |
72 | - $rules['title'] = 'required|between:4,65|unique:'.$this->modelGroup->getTable().',title,'.$newsGroupId; |
|
72 | + $rules['title'] = 'required|between:4,65|unique:'.$this->modelGroup->getTable().',title,'.$newsGroupId; |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | return $validator; |
128 | 128 | } |
129 | 129 | |
130 | - $filename = str_replace(" ", "_", strtolower($attributes['file']->getClientOriginalName())); |
|
130 | + $filename = str_replace(" ", "_", strtolower($attributes['file']->getClientOriginalName())); |
|
131 | 131 | $uploadSuccess = $attributes['file']->move($destinationPath, $filename); |
132 | 132 | |
133 | 133 | if ($uploadSuccess) { |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | |
193 | 193 | if (!File::exists($this->publicImagePath.$valueImage."/".$productImage->news_id."/".$productImage->file)) { |
194 | 194 | if (File::exists($this->storageImagePath.$productImage->news_id."/".$productImage->file)) { |
195 | - $image = Image::make(storage_path() .config('hideyo.storage_path'). "//news/".$productImage->news_id."/".$productImage->file); |
|
195 | + $image = Image::make(storage_path().config('hideyo.storage_path')."//news/".$productImage->news_id."/".$productImage->file); |
|
196 | 196 | $explode = explode('x', $valueImage); |
197 | 197 | $image->fit($explode[0], $explode[1]); |
198 | 198 | |
199 | 199 | $image->interlace(); |
200 | 200 | |
201 | - $image->save(public_path() .config('hideyo.storage_path'). "/news/".$valueImage."/".$productImage->news_id."/".$productImage->file); |
|
201 | + $image->save(public_path().config('hideyo.storage_path')."/news/".$valueImage."/".$productImage->news_id."/".$productImage->file); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - $directory = app_path() . "/storage/files/news/".$this->model->id; |
|
260 | + $directory = app_path()."/storage/files/news/".$this->model->id; |
|
261 | 261 | File::deleteDirectory($directory); |
262 | 262 | |
263 | 263 | return $this->model->delete(); |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | |
326 | 326 | function selectAllByBlogCategoryId($newsCategoryId) |
327 | 327 | { |
328 | - return $this->model->with(array('extraFields' => function ($query) { |
|
329 | - }, 'taxRate', 'newsCategory', 'relatedBlogs' => function ($query) { |
|
328 | + return $this->model->with(array('extraFields' => function($query) { |
|
329 | + }, 'taxRate', 'newsCategory', 'relatedBlogs' => function($query) { |
|
330 | 330 | $query->with('newsImages')->orderBy('rank', 'asc'); |
331 | - }, 'newsImages' => function ($query) { |
|
331 | + }, 'newsImages' => function($query) { |
|
332 | 332 | $query->orderBy('rank', 'asc'); |
333 | 333 | }))->where('active', '=', 1)->where('news_category_id', '=', $newsCategoryId)->get(); |
334 | 334 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | function selectOneById($shopId, $slug) |
337 | 337 | { |
338 | 338 | $dt = Carbon::now('Europe/Amsterdam'); |
339 | - $result = $this->model->with(array('newsCategory', 'relatedBlogs', 'newsImages' => function ($query) { |
|
339 | + $result = $this->model->with(array('newsCategory', 'relatedBlogs', 'newsImages' => function($query) { |
|
340 | 340 | $query->orderBy('rank', 'asc'); |
341 | 341 | }))->where('published_at', '<=', $dt->toDateString('Y-m-d'))->where('active', '=', 1)->where('id', '=', $id)->get()->first(); |
342 | 342 | return $result; |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $dt = Carbon::now('Europe/Amsterdam'); |
363 | 363 | |
364 | 364 | return $this->model->with( |
365 | - array('newsImages' => function ($query) { |
|
365 | + array('newsImages' => function($query) { |
|
366 | 366 | $query->orderBy('rank', 'asc'); |
367 | 367 | }) |
368 | 368 | ) |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $result = $this->model |
396 | 396 | ->where('shop_id', '=', $shopId) |
397 | 397 | ->where('published_at', '<=', $dt->toDateString('Y-m-d')) |
398 | - ->whereHas('newsGroup', function ($query) use ($newsGroupSlug) { |
|
398 | + ->whereHas('newsGroup', function($query) use ($newsGroupSlug) { |
|
399 | 399 | $query->where('slug', '=', $newsGroupSlug); |
400 | 400 | }); |
401 | 401 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | |
11 | 11 | class AttributeService extends BaseService |
12 | 12 | { |
13 | - public function __construct(AttributeRepository $attribute, AttributeGroupRepository $attributeGroup) |
|
14 | - { |
|
15 | - $this->repo = $attribute; |
|
16 | - $this->repoGroup = $attributeGroup; |
|
17 | - } |
|
13 | + public function __construct(AttributeRepository $attribute, AttributeGroupRepository $attributeGroup) |
|
14 | + { |
|
15 | + $this->repo = $attribute; |
|
16 | + $this->repoGroup = $attributeGroup; |
|
17 | + } |
|
18 | 18 | |
19 | 19 | |
20 | 20 | public function rules($id = false) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function create(array $attributes, $attributeGroupId) |
49 | 49 | { |
50 | 50 | $attributes['shop_id'] = auth('hideyobackend')->user()->selected_shop_id; |
51 | - $attributes['attribute_group_id'] = $attributeGroupId; |
|
51 | + $attributes['attribute_group_id'] = $attributeGroupId; |
|
52 | 52 | |
53 | 53 | $validator = Validator::make($attributes, $this->rules()); |
54 | 54 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | ); |
39 | 39 | |
40 | 40 | if ($id) { |
41 | - $rules['title'] = 'required|between:1,65|unique_with:'.$this->repoGroup->getModel()->getTable().', shop_id, '.$id.' = id'; |
|
41 | + $rules['title'] = 'required|between:1,65|unique_with:'.$this->repoGroup->getModel()->getTable().', shop_id, '.$id.' = id'; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return $rules; |
@@ -9,10 +9,10 @@ |
||
9 | 9 | |
10 | 10 | class ExtraFieldService extends BaseService |
11 | 11 | { |
12 | - public function __construct(ExtraFieldRepository $extraField) |
|
13 | - { |
|
14 | - $this->repo = $extraField; |
|
15 | - } |
|
12 | + public function __construct(ExtraFieldRepository $extraField) |
|
13 | + { |
|
14 | + $this->repo = $extraField; |
|
15 | + } |
|
16 | 16 | |
17 | 17 | |
18 | 18 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | ); |
46 | 46 | |
47 | 47 | if ($extraFieldId) { |
48 | - $rules['title'] = 'required|between:4,65|unique_with:'.$this->repo->getModel()->getTable().', shop_id, '.$extraFieldId.' = id'; |
|
48 | + $rules['title'] = 'required|between:4,65|unique_with:'.$this->repo->getModel()->getTable().', shop_id, '.$extraFieldId.' = id'; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $rules; |
@@ -34,10 +34,10 @@ |
||
34 | 34 | return $this->model->select('extra_field.*') |
35 | 35 | ->leftJoin('product_category_related_extra_field', 'extra_field.id', '=', 'product_category_related_extra_field.extra_field_id') |
36 | 36 | |
37 | - ->where(function ($query) use ($productCategoryId) { |
|
37 | + ->where(function($query) use ($productCategoryId) { |
|
38 | 38 | |
39 | 39 | $query->where('all_products', '=', 1) |
40 | - ->orWhereHas('categories', function ($query) use ($productCategoryId) { |
|
40 | + ->orWhereHas('categories', function($query) use ($productCategoryId) { |
|
41 | 41 | |
42 | 42 | $query->where('product_category_id', '=', $productCategoryId); |
43 | 43 | }); |