public function onRun() { $this->addJs('assets/js/product.js'); $slug = $this->param('slug'); $product = Product::where('slug', $slug)->isPublished()->first(); $this->page['product'] = $product; $this->page->title = $product->title; $this->page->url = $this->pageUrl('store/item', ['slug' => $product->{$slug}]); $this->page['image_url'] = 'http://allianceeducation.ca' . $product->featured_images[0]->path; }
protected function updateOrderItems($order, $product, $quantity) { if (is_array($product)) { foreach ($product as $key => $item) { $prod = Product::where('id', $item)->first(); $rebate = $prod->price * $prod->promotion / 100; OrderItem::where('order_id', $order)->where('product_id', $item)->update(['quantity' => $quantity[$key], 'subtotal' => $quantity[$key] * ($prod->price - $rebate)]); } } }