/** * Turn this item object into a generic array * * @return array */ public function transform(MenuOrderProduct $mop) { $menuProductData = $this->processItem($mop->menuProduct()->first(), new MenuProductsTransformer()); return array_merge($menuProductData, ['qta' => $mop->getQuantity()]); }
/** * Relazione al User * * @return MenuOrderProduct */ public function addMenuProduct(Menu $menu, Product $product, $qta) { $menuProduct = MenuProduct::where(['product_id' => $product->id, 'menu_id' => $menu->id])->firstOrFail(); $menuOrderProduct = MenuOrderProduct::create(['menu_product_id' => $menuProduct->id, 'order_id' => $this->id, 'quantity' => $qta, 'referator_label' => $this->user()->first()->display_name]); return $menuOrderProduct; }