/** * @return PubRepository * @throws \DataBaseException * @throws \Exception */ public function getPubs() { $pubRepository = $this->pubDAL->getPubs(); $beerRepository = $this->beerDAL->getBeers(); $pubBeers = $this->getPubBeers(); // Goes through the pubs.. foreach ($pubRepository->get() as $pub) { // and each beer.. foreach ($beerRepository->get() as $beer) { // lastly each "post" in the relational table foreach ($pubBeers->get() as $pubBeer) { // checks for a connection between beer and pub if ($pub->getId() === $pubBeer->getPubId() && $beer->getId() === $pubBeer->getBeerId()) { $beer->setPrice($pubBeer->getPrice()); $pub->addBeer($beer); } } } } return $pubRepository; }
/** * @return PubRepository * @throws \DataBaseException */ public function getPubs() { return $this->pubDAL->getPubs(); }