src/Entity/CarOwner.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CarOwnerRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CarOwnerRepository::class)
  9.  */
  10. class CarOwner
  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="string", length=500, nullable=true)
  24.      */
  25.     private $address;
  26.     /**
  27.      * @ORM\Column(type="string", length=30, nullable=true)
  28.      */
  29.     private $phone;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $mail;
  34.     /**
  35.      * @ORM\Column(type="boolean")
  36.      */
  37.     private $send_mail;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=Cars::class, mappedBy="owners")
  40.      */
  41.     private $cars;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=Cars::class, mappedBy="contact")
  44.      */
  45.     private $contactCars;
  46.         /**
  47.      * @ORM\Column(type="text", nullable=true)
  48.      */
  49.     private $note;
  50.     public function __construct()
  51.     {
  52.         $this->cars = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getName(): ?string
  59.     {
  60.         return $this->name;
  61.     }
  62.     public function setName(string $name): self
  63.     {
  64.         $this->name = $name;
  65.         return $this;
  66.     }
  67.     public function getAddress(): ?string
  68.     {
  69.         return $this->address;
  70.     }
  71.     public function setAddress(?string $address): self
  72.     {
  73.         $this->address = $address;
  74.         return $this;
  75.     }
  76.     public function getPhone(): ?string
  77.     {
  78.         return $this->phone;
  79.     }
  80.     public function setPhone(?string $phone): self
  81.     {
  82.         $this->phone = $phone;
  83.         return $this;
  84.     }
  85.     public function getMail(): ?string
  86.     {
  87.         return $this->mail;
  88.     }
  89.     public function setMail(?string $mail): self
  90.     {
  91.         $this->mail = $mail;
  92.         return $this;
  93.     }
  94.     public function isSendMail(): ?bool
  95.     {
  96.         return $this->send_mail;
  97.     }
  98.     public function setSendMail(bool $send_mail): self
  99.     {
  100.         $this->send_mail = $send_mail;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, Cars>
  105.      */
  106.     public function getAllCars(): Collection
  107.     {
  108.         return new ArrayCollection(array_merge($this->cars->toArray(), $this->contactCars->toArray()));
  109.         //return $this->cars;
  110.     }
  111.     /**
  112.      * @return Collection<int, Cars>
  113.      */
  114.     public function getCars(): Collection
  115.     {
  116.         return $this->cars;
  117.     }
  118.     public function addCar(Cars $car): self
  119.     {
  120.         if (!$this->cars->contains($car)) {
  121.             $this->cars[] = $car;
  122.             $car->setOwners($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeCar(Cars $car): self
  127.     {
  128.         if ($this->cars->removeElement($car)) {
  129.             // set the owning side to null (unless already changed)
  130.             if ($car->getOwners() === $this) {
  131.                 $car->setOwners(null);
  132.             }
  133.         }
  134.         return $this;
  135.     }
  136.     /**
  137.      * @return Collection<int, Cars>
  138.      */
  139.     public function getContactCars(): Collection
  140.     {
  141.         return $this->contactCars;
  142.     }
  143.     public function addContactCar(Cars $car): self
  144.     {
  145.         if (!$this->cars->contains($car)) {
  146.             $this->contactCars[] = $car;
  147.             $car->setOwners($this);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeContactCar(Cars $car): self
  152.     {
  153.         if ($this->contactCars->removeElement($car)) {
  154.             // set the owning side to null (unless already changed)
  155.             if ($car->getOwners() === $this) {
  156.                 $car->setOwners(null);
  157.             }
  158.         }
  159.         return $this;
  160.     }
  161.     public function __toString()
  162.     {
  163.         return $this->getName();
  164.     }
  165.     public function getNote(): ?string
  166.     {
  167.         return $this->note;
  168.     }
  169.     public function setNote(?string $note): self
  170.     {
  171.         $this->note = $note;
  172.         return $this;
  173.     }
  174.     public function getSearchFields(): ?string
  175.     {
  176.         return $this->name." | ".$this->address." | ".$this->mail." | ".$this->note;
  177.     }
  178. }