Esempio n. 1
0
 /**
  * Aggiunge un prodotto al menu
  *
  * @param Product $product
  * @param int $availability (optional) -> infinite
  * @param float $price (optional) -> Product Inherithed
  * @return Menu
  */
 public function addProduct(Product $product, $availability = null, $price = null)
 {
     $price = !is_null($price) && is_float($price) ? $price : $product->getPrice();
     MenuProduct::create(['availability' => $availability, 'price' => $price, 'product_id' => $product->id, 'menu_id' => $this->id]);
     return $this;
 }
 /**
  * Turn this item object into a generic array
  *
  * @return array
  */
 public function transform(Product $product)
 {
     return ['id' => $product->id, 'name' => $product->getName(), 'price' => $product->getPrice(), 'category' => $product->getCategory()];
 }
 private function renderProduct(Product $p, $isNew = false)
 {
     $name = $p->getName() . ($isNew ? ' [NUOVO]' : '');
     return $name . ' - € ' . $p->getPrice() . ' - ' . $p->getCategory();
 }