src/Entity/ContractPrice/Contract.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ContractPrice;
  3. use App\Entity\Extension\HistoricalInterface;
  4. use App\Entity\Extension\HistoricalTrait;
  5. use App\Entity\Extension\TimestampableTrait;
  6. use App\Entity\Extension\UnlistableTrait;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use App\Entity\Gauge\Supplier;
  11. use App\Entity\File;
  12. use App\Entity\Gauge\Gauge;
  13. use App\Repository\ContractPrice\ContractRepository;
  14. use Ramsey\Uuid\UuidInterface;
  15. /**
  16. * @ORM\Entity(repositoryClass=ContractRepository::class)
  17. * @ORM\Table(name="contract")
  18. */
  19. class Contract implements HistoricalInterface
  20. {
  21. use TimestampableTrait;
  22. use UnlistableTrait;
  23. use HistoricalTrait;
  24. /**
  25. * @var ?UuidInterface
  26. *
  27. * @ORM\Id()
  28. * @ORM\GeneratedValue(strategy="CUSTOM")
  29. * @ORM\Column(type="uuid", unique=true)
  30. * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
  31. */
  32. private ?UuidInterface $id;
  33. /**
  34. * @ORM\ManyToOne(targetEntity=Supplier::class)
  35. * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id", nullable=false)
  36. */
  37. private Supplier $supplier;
  38. /**
  39. * @ORM\ManyToOne(targetEntity=File::class)
  40. * @ORM\JoinColumn(name="file_id", referencedColumnName="id", nullable=true)
  41. */
  42. private ?File $file = null;
  43. /**
  44. * @ORM\Column(type="boolean", nullable=false)
  45. */
  46. private bool $manual = false;
  47. /**
  48. * E.g. "electricity", "gas" ...
  49. * @ORM\Column(type="integer", nullable=true)
  50. */
  51. private ?int $medium = null;
  52. /**
  53. * @ORM\Column(type="string", nullable=true)
  54. */
  55. private ?string $deliveryMethod = null;
  56. /**
  57. * @ORM\Column(type="date")
  58. */
  59. private \DateTimeInterface $validTo;
  60. /**
  61. * @ORM\OneToMany(targetEntity=ContractItem::class, mappedBy="contract", cascade={"persist","remove"})
  62. * @var Collection|ContractItem[]
  63. */
  64. private $items;
  65. /**
  66. * @ORM\ManyToMany(targetEntity=Gauge::class)
  67. * @ORM\JoinTable(name="gauges_contract",
  68. * joinColumns={@ORM\JoinColumn(name="contract_price_id", referencedColumnName="id")},
  69. * inverseJoinColumns={@ORM\JoinColumn(name="gauge_id", referencedColumnName="id", onDelete="CASCADE")}
  70. * )
  71. * @var Collection|Gauge[]
  72. */
  73. private $gauges;
  74. public function __construct()
  75. {
  76. $this->items = new ArrayCollection();
  77. $this->gauges = new ArrayCollection();
  78. }
  79. public function getId(): ?string
  80. {
  81. return $this->id;
  82. }
  83. public function hasId(): bool
  84. {
  85. return isset($this->id);
  86. }
  87. public function getSupplier(): Supplier
  88. {
  89. return $this->supplier;
  90. }
  91. public function setSupplier(Supplier $supplier): self
  92. {
  93. $this->supplier = $supplier;
  94. return $this;
  95. }
  96. public function getFile(): ?File
  97. {
  98. return $this->file;
  99. }
  100. public function setFile(?File $file): self
  101. {
  102. $this->file = $file;
  103. return $this;
  104. }
  105. public function getManual(): bool
  106. {
  107. return $this->manual;
  108. }
  109. public function setManual(bool $manual): self
  110. {
  111. $this->manual = $manual;
  112. return $this;
  113. }
  114. public function getMedium(): ?int
  115. {
  116. return $this->medium;
  117. }
  118. public function setMedium(?string $medium): self
  119. {
  120. $this->medium = $medium;
  121. return $this;
  122. }
  123. public function getDeliveryMethod(): ?string
  124. {
  125. return $this->deliveryMethod;
  126. }
  127. public function setDeliveryMethod(?string $deliveryMethod): self
  128. {
  129. $this->deliveryMethod = $deliveryMethod;
  130. return $this;
  131. }
  132. public function getValidTo(): \DateTimeInterface
  133. {
  134. return $this->validTo;
  135. }
  136. public function setValidTo(\DateTimeInterface $validTo): self
  137. {
  138. $this->validTo = $validTo;
  139. return $this;
  140. }
  141. /** @return Collection<int, ContractItem> */
  142. public function getItems(): Collection
  143. {
  144. return $this->items;
  145. }
  146. public function addItem(ContractItem $item): self
  147. {
  148. if (!$this->items->contains($item)) {
  149. $this->items[] = $item;
  150. $item->setContract($this);
  151. }
  152. return $this;
  153. }
  154. public function removeItem(ContractItem $item): self
  155. {
  156. $this->items->removeElement($item);
  157. return $this;
  158. }
  159. /** @return Collection<int, Gauge> */
  160. public function getGauges(): Collection
  161. {
  162. return $this->gauges;
  163. }
  164. public function addGauge(Gauge $gauge): self
  165. {
  166. if (!$this->gauges->contains($gauge)) {
  167. $this->gauges[] = $gauge;
  168. }
  169. return $this;
  170. }
  171. public function removeGauge(Gauge $gauge): self
  172. {
  173. $this->gauges->removeElement($gauge);
  174. return $this;
  175. }
  176. }