src/Entity/Customers.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CustomersRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: CustomersRepository::class)]
  8. class Customers
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column(type: 'integer')]
  13. private $id;
  14. #[ORM\Column(type: 'string', length: 255)]
  15. private $name;
  16. #[ORM\Column(type: 'text', nullable: true)]
  17. private $address;
  18. #[ORM\Column(type: 'text', nullable: true)]
  19. private $note;
  20. #[ORM\Column(type: 'datetime', nullable: true)]
  21. private $created;
  22. #[ORM\OneToMany(targetEntity: Projects::class, mappedBy: 'customer')]
  23. private $projects;
  24. #[ORM\OneToMany(targetEntity: Contracts::class, mappedBy: 'customer')]
  25. private $contracts;
  26. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  27. private $phone;
  28. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  29. private $email;
  30. public function __construct()
  31. {
  32. $this->projects = new ArrayCollection();
  33. $this->created = new \DateTime();
  34. $this->contracts = new ArrayCollection();
  35. $this->contracts = new ArrayCollection();
  36. }
  37. public function getId(): ?int
  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. public function getAddress(): ?string
  51. {
  52. return $this->address;
  53. }
  54. public function setAddress(?string $address): self
  55. {
  56. $this->address = $address;
  57. return $this;
  58. }
  59. public function getNote(): ?string
  60. {
  61. return $this->note;
  62. }
  63. public function setNote(?string $note): self
  64. {
  65. $this->note = $note;
  66. return $this;
  67. }
  68. public function getCreated(): ?\DateTimeInterface
  69. {
  70. return $this->created;
  71. }
  72. public function setCreated(?\DateTimeInterface $created): self
  73. {
  74. $this->created = $created;
  75. return $this;
  76. }
  77. /**
  78. * @return Collection|Projects[]
  79. */
  80. public function getProjects(): Collection
  81. {
  82. return $this->projects;
  83. }
  84. public function addProject(Projects $project): self
  85. {
  86. if (!$this->projects->contains($project)) {
  87. $this->projects[] = $project;
  88. $project->setCustomer($this);
  89. }
  90. return $this;
  91. }
  92. public function removeProject(Projects $project): self
  93. {
  94. if ($this->projects->removeElement($project)) {
  95. // set the owning side to null (unless already changed)
  96. if ($project->getCustomer() === $this) {
  97. $project->setCustomer(null);
  98. }
  99. }
  100. return $this;
  101. }
  102. public function __toString()
  103. {
  104. return $this->name;
  105. }
  106. /**
  107. * @return Collection|Contracts[]
  108. */
  109. public function getContracts(): Collection
  110. {
  111. return $this->contracts;
  112. }
  113. public function addContract(Contracts $contract): self
  114. {
  115. if (!$this->contracts->contains($contract)) {
  116. $this->contracts[] = $contract;
  117. $contract->setCustomer($this);
  118. }
  119. return $this;
  120. }
  121. public function removeContract(Contracts $contract): self
  122. {
  123. if ($this->contracts->removeElement($contract)) {
  124. // set the owning side to null (unless already changed)
  125. if ($contract->getCustomer() === $this) {
  126. $contract->setCustomer(null);
  127. }
  128. }
  129. return $this;
  130. }
  131. public function getPhone(): ?string
  132. {
  133. return $this->phone;
  134. }
  135. public function setPhone(?string $phone): self
  136. {
  137. $this->phone = $phone;
  138. return $this;
  139. }
  140. public function getEmail(): ?string
  141. {
  142. return $this->email;
  143. }
  144. public function setEmail(?string $email): self
  145. {
  146. $this->email = $email;
  147. return $this;
  148. }
  149. }