src/Entity/Institution.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Abstract\Entity;
  4. use App\Repository\InstitutionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Uid\Uuid;
  9. #[ORM\Entity(repositoryClass: InstitutionRepository::class)]
  10. class Institution extends Entity
  11. {
  12. #[ORM\Id]
  13. #[ORM\Column(type: 'uuid', unique: true)]
  14. #[ORM\GeneratedValue(strategy: 'CUSTOM')]
  15. #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
  16. private ?Uuid $id = null;
  17. #[ORM\Column(length: 100)]
  18. #[Gedmo\Versioned]
  19. private ?string $name = null;
  20. #[ORM\ManyToMany(targetEntity: Enterprise::class, inversedBy: 'participations')]
  21. private Collection $participation;
  22. #[ORM\OneToOne(cascade: ['persist', 'remove'])]
  23. #[Gedmo\Versioned]
  24. private ?Address $address = null;
  25. #[ORM\OneToMany(mappedBy: 'institution', targetEntity: Discount::class, cascade: ['persist', 'remove'])]
  26. private Collection $discounts;
  27. #[ORM\Column(length: 50, nullable: true)]
  28. #[Gedmo\Versioned]
  29. private ?string $customerNumber = null;
  30. #[ORM\ManyToOne(inversedBy: 'institutions')]
  31. protected ?User $createdBy = null;
  32. public function __construct()
  33. {
  34. $this->participation = new ArrayCollection();
  35. $this->discounts = new ArrayCollection();
  36. }
  37. public function getId(): ?Uuid
  38. {
  39. return $this->id;
  40. }
  41. public function getName(): ?string
  42. {
  43. return $this->name;
  44. }
  45. public function setName(string $name): self
  46. {
  47. $this->name = $name;
  48. return $this;
  49. }
  50. /**
  51. * @return Collection<int, Enterprise>
  52. */
  53. public function getParticipation(): Collection
  54. {
  55. return $this->participation;
  56. }
  57. public function addParticipation(Enterprise $participation): self
  58. {
  59. if (!$this->participation->contains($participation)) {
  60. $this->participation->add($participation);
  61. }
  62. return $this;
  63. }
  64. public function removeParticipation(Enterprise $participation): self
  65. {
  66. $this->participation->removeElement($participation);
  67. return $this;
  68. }
  69. public function getAddress(): ?Address
  70. {
  71. return $this->address;
  72. }
  73. public function setAddress(?Address $address): self
  74. {
  75. $this->address = $address;
  76. return $this;
  77. }
  78. /**
  79. * @return Collection<int, Discount>
  80. */
  81. public function getDiscounts(): Collection
  82. {
  83. return $this->discounts;
  84. }
  85. public function addDiscount(Discount $discount): self
  86. {
  87. if (!$this->discounts->contains($discount)) {
  88. $this->discounts->add($discount);
  89. $discount->setInstitution($this);
  90. }
  91. return $this;
  92. }
  93. public function removeDiscount(Discount $discount): self
  94. {
  95. if ($this->discounts->removeElement($discount)) {
  96. // set the owning side to null (unless already changed)
  97. if ($discount->getInstitution() === $this) {
  98. $discount->setInstitution(null);
  99. }
  100. }
  101. return $this;
  102. }
  103. public function getCustomerNumber(): ?string
  104. {
  105. return $this->customerNumber;
  106. }
  107. public function setCustomerNumber(?string $customerNumber): self
  108. {
  109. $this->customerNumber = $customerNumber;
  110. return $this;
  111. }
  112. }