|
2 | 2 |
|
3 | 3 | namespace App\Entity; |
4 | 4 |
|
| 5 | +use Doctrine\Common\Collections\ArrayCollection; |
| 6 | +use Doctrine\Common\Collections\Collection; |
5 | 7 | use Doctrine\ORM\Mapping as ORM; |
6 | 8 |
|
7 | 9 | /** |
@@ -32,6 +34,16 @@ class Restaurant |
32 | 34 | */ |
33 | 35 | private $city; |
34 | 36 |
|
| 37 | + /** |
| 38 | + * @ORM\OneToMany(targetEntity="App\Entity\RestaurantPicture", mappedBy="restaurant", orphanRemoval=true) |
| 39 | + */ |
| 40 | + private $restaurantPictures; |
| 41 | + |
| 42 | + public function __construct() |
| 43 | + { |
| 44 | + $this->restaurantPictures = new ArrayCollection(); |
| 45 | + } |
| 46 | + |
35 | 47 | public function getId(): ?int |
36 | 48 | { |
37 | 49 | return $this->id; |
@@ -72,4 +84,35 @@ public function setCity(?City $city): self |
72 | 84 |
|
73 | 85 | return $this; |
74 | 86 | } |
| 87 | + |
| 88 | + /** |
| 89 | + * @return Collection|RestaurantPicture[] |
| 90 | + */ |
| 91 | + public function getRestaurantPictures(): Collection |
| 92 | + { |
| 93 | + return $this->restaurantPictures; |
| 94 | + } |
| 95 | + |
| 96 | + public function addRestaurantPicture(RestaurantPicture $restaurantPicture): self |
| 97 | + { |
| 98 | + if (!$this->restaurantPictures->contains($restaurantPicture)) { |
| 99 | + $this->restaurantPictures[] = $restaurantPicture; |
| 100 | + $restaurantPicture->setRestaurant($this); |
| 101 | + } |
| 102 | + |
| 103 | + return $this; |
| 104 | + } |
| 105 | + |
| 106 | + public function removeRestaurantPicture(RestaurantPicture $restaurantPicture): self |
| 107 | + { |
| 108 | + if ($this->restaurantPictures->contains($restaurantPicture)) { |
| 109 | + $this->restaurantPictures->removeElement($restaurantPicture); |
| 110 | + // set the owning side to null (unless already changed) |
| 111 | + if ($restaurantPicture->getRestaurant() === $this) { |
| 112 | + $restaurantPicture->setRestaurant(null); |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + return $this; |
| 117 | + } |
75 | 118 | } |
0 commit comments