Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. <?php
  2.  
  3. ############################
  4. # MenuAudience
  5. ############################
  6.  
  7. namespace App\Entity;
  8.  
  9.  
  10. use ApiPlatform\Core\Annotation\ApiResource;
  11. use ApiPlatform\Core\Annotation\ApiFilter;
  12. use App\Repository\MenuAudienceRepository;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16.  
  17. /**
  18. * @ApiResource(
  19. * collectionOperations={"get", "post"},
  20. * itemOperations={"get", "put", "delete"},
  21. * )
  22. * @ORM\Entity(repositoryClass=MenuAudienceRepository::class)
  23. */
  24. class MenuAudience
  25. {
  26. /**
  27. * @ORM\Id()
  28. * @ORM\GeneratedValue()
  29. * @ORM\Column(type="integer")
  30. */
  31. private $id;
  32.  
  33. /**
  34. * @ORM\Column(type="string", length=100)
  35. */
  36. private $name;
  37.  
  38. /**
  39. * @ORM\Column(type="string", length=255)
  40. */
  41. private $description;
  42.  
  43. /**
  44. * @ORM\Column(type="boolean")
  45. */
  46. private $published;
  47.  
  48. /**
  49. * @ORM\Column(type="integer")
  50. */
  51. private $orderNumber;
  52.  
  53. /**
  54. * @ORM\OneToMany(targetEntity=MealAudienceCategory::class, mappedBy="menuAudience", orphanRemoval=true)
  55. */
  56. private $mealAudienceCategories;
  57.  
  58. public function __construct()
  59. {
  60. $this->mealAudienceCategories = new ArrayCollection();
  61. }
  62.  
  63. public function getId(): ?int
  64. {
  65. return $this->id;
  66. }
  67.  
  68. public function getName(): ?string
  69. {
  70. return $this->name;
  71. }
  72.  
  73. public function setName(string $name): self
  74. {
  75. $this->name = $name;
  76.  
  77. return $this;
  78. }
  79.  
  80. public function getDescription(): ?string
  81. {
  82. return $this->description;
  83. }
  84.  
  85. public function setDescription(string $description): self
  86. {
  87. $this->description = $description;
  88.  
  89. return $this;
  90. }
  91.  
  92. public function getPublished(): ?bool
  93. {
  94. return $this->published;
  95. }
  96.  
  97. public function setPublished(bool $published): self
  98. {
  99. $this->published = $published;
  100.  
  101. return $this;
  102. }
  103.  
  104. public function getOrderNumber(): ?int
  105. {
  106. return $this->orderNumber;
  107. }
  108.  
  109. public function setOrderNumber(int $orderNumber): self
  110. {
  111. $this->orderNumber = $orderNumber;
  112.  
  113. return $this;
  114. }
  115.  
  116. /**
  117. * @return Collection|MealAudienceCategory[]
  118. */
  119. public function getMealAudienceCategories(): Collection
  120. {
  121. return $this->mealAudienceCategories;
  122. }
  123.  
  124. public function addMealAudienceCategory(MealAudienceCategory $mealAudienceCategory): self
  125. {
  126. if (!$this->mealAudienceCategories->contains($mealAudienceCategory)) {
  127. $this->mealAudienceCategories[] = $mealAudienceCategory;
  128. $mealAudienceCategory->setMenuAudience($this);
  129. }
  130.  
  131. return $this;
  132. }
  133.  
  134. public function removeMealAudienceCategory(MealAudienceCategory $mealAudienceCategory): self
  135. {
  136. if ($this->mealAudienceCategories->contains($mealAudienceCategory)) {
  137. $this->mealAudienceCategories->removeElement($mealAudienceCategory);
  138. // set the owning side to null (unless already changed)
  139. if ($mealAudienceCategory->getMenuAudience() === $this) {
  140. $mealAudienceCategory->setMenuAudience(null);
  141. }
  142. }
  143.  
  144. return $this;
  145. }
  146. }
  147.  
  148. ############################
  149. # MealAudienceCategory
  150. ############################
  151.  
  152. <?php
  153.  
  154. namespace App\Entity;
  155.  
  156.  
  157. use ApiPlatform\Core\Annotation\ApiResource;
  158. use ApiPlatform\Core\Annotation\ApiFilter;
  159. use App\Repository\MealAudienceCategoryRepository;
  160. use Doctrine\Common\Collections\ArrayCollection;
  161. use Doctrine\Common\Collections\Collection;
  162. use Doctrine\ORM\Mapping as ORM;
  163.  
  164. /**
  165. * @ApiResource(
  166. * collectionOperations={"get", "post"},
  167. * itemOperations={"get", "put", "delete"},
  168. * )
  169. * @ORM\Entity(repositoryClass=MealAudienceCategoryRepository::class)
  170. */
  171. class MealAudienceCategory
  172. {
  173. /**
  174. * @ORM\Id()
  175. * @ORM\GeneratedValue()
  176. * @ORM\Column(type="integer")
  177. */
  178. private $id;
  179.  
  180. /**
  181. * @ORM\Column(type="string", length=50)
  182. */
  183. private $name;
  184.  
  185. /**
  186. * @ORM\Column(type="string", length=255)
  187. */
  188. private $description;
  189.  
  190. /**
  191. * @ORM\Column(type="integer")
  192. */
  193. private $orderNumber;
  194.  
  195. /**
  196. * @ORM\Column(type="boolean")
  197. */
  198. private $published;
  199.  
  200. /**
  201. * @ORM\ManyToOne(targetEntity=menuAudience::class, inversedBy="mealAudienceCategories")
  202. * @ORM\JoinColumn(nullable=false)
  203. */
  204. private $menuAudience;
  205.  
  206. public function getId(): ?int
  207. {
  208. return $this->id;
  209. }
  210.  
  211. public function getName(): ?string
  212. {
  213. return $this->name;
  214. }
  215.  
  216. public function setName(string $name): self
  217. {
  218. $this->name = $name;
  219.  
  220. return $this;
  221. }
  222.  
  223. public function getDescription(): ?string
  224. {
  225. return $this->description;
  226. }
  227.  
  228. public function setDescription(string $description): self
  229. {
  230. $this->description = $description;
  231.  
  232. return $this;
  233. }
  234.  
  235. public function getOrderNumber(): ?int
  236. {
  237. return $this->orderNumber;
  238. }
  239.  
  240. public function setOrderNumber(int $orderNumber): self
  241. {
  242. $this->orderNumber = $orderNumber;
  243.  
  244. return $this;
  245. }
  246.  
  247. public function getPublished(): ?bool
  248. {
  249. return $this->published;
  250. }
  251.  
  252. public function setPublished(bool $published): self
  253. {
  254. $this->published = $published;
  255.  
  256. return $this;
  257. }
  258.  
  259. public function getMenuAudience(): ?menuAudience
  260. {
  261. return $this->menuAudience;
  262. }
  263.  
  264. public function setMenuAudience(?menuAudience $menuAudience): self
  265. {
  266. $this->menuAudience = $menuAudience;
  267.  
  268. return $this;
  269. }
  270. }
  271.  
  272.  
  273.  
  274.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement