/** * Set the associated Restaurateur * Be Careful ! To register a link between a Restaurateur and a Restaurant, * you should use Restaurateur->addRestaurant instead ! Otherwise the * Restaurant will not be added to the Restaurateur. * @param \App\Model\Restaurateur $restaurateur */ public function setRestaurateur(Restaurateur $restaurateur) { $this->restaurateur = $restaurateur->getId(); }
/** * Get all the Commande from the corresponding Restaurateur * @param \App\Model\Restaurateur $restaurateur * @return \App\Model\Commande[] */ public static function getByRestaurateur(Restaurateur $restaurateur) { $commandes = self::getBy(array()); $foundCommandes = array(); foreach ($commandes as $commande) { $items = $commande->getItems(); $item = ItemMenu::getOneBy(array('_id' => $items[0]->getId())); if ($item->getMenu()->getRestaurant()->getRestaurateur() && $item->getMenu()->getRestaurant()->getRestaurateur()->getId() == $restaurateur->getId()) { $foundCommandes[] = $commande; } } return $foundCommandes; }