|
@@ 217-225 (lines=9) @@
|
| 214 |
|
$products = $products->merge($category->products); |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
foreach ($products as $product) { |
| 218 |
|
$data[] = [ |
| 219 |
|
'discount_id' => $discount->id, |
| 220 |
|
'end_at' => $discount->end_at, |
| 221 |
|
'price' => $discount->calculatePrice($product->base_price), |
| 222 |
|
'product_id' => $product->id, |
| 223 |
|
'start_at' => $discount->start_at, |
| 224 |
|
]; |
| 225 |
|
} |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
Price::whereNotNull('discount_id')->delete(); |
|
@@ 244-252 (lines=9) @@
|
| 241 |
|
->get(); |
| 242 |
|
|
| 243 |
|
$data = []; |
| 244 |
|
foreach ($discounts as $discount) { |
| 245 |
|
$data[] = [ |
| 246 |
|
'discount_id' => $discount->id, |
| 247 |
|
'end_at' => $discount->end_at, |
| 248 |
|
'price' => $discount->calculatePrice($product->base_price), |
| 249 |
|
'product_id' => $product->id, |
| 250 |
|
'start_at' => $discount->start_at, |
| 251 |
|
]; |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
Price::whereProductId($product->id)->whereIn('discount_id', $discounts->lists('id'))->delete(); |
| 255 |
|
Price::insert($data); |