src/Entity/Customers.php line 13

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