<?php
namespace App\Entity;
use App\Repository\CarOwnerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CarOwnerRepository::class)
*/
class CarOwner
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=500, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=30, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mail;
/**
* @ORM\Column(type="boolean")
*/
private $send_mail;
/**
* @ORM\OneToMany(targetEntity=Cars::class, mappedBy="owners")
*/
private $cars;
/**
* @ORM\OneToMany(targetEntity=Cars::class, mappedBy="contact")
*/
private $contactCars;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $note;
public function __construct()
{
$this->cars = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getMail(): ?string
{
return $this->mail;
}
public function setMail(?string $mail): self
{
$this->mail = $mail;
return $this;
}
public function isSendMail(): ?bool
{
return $this->send_mail;
}
public function setSendMail(bool $send_mail): self
{
$this->send_mail = $send_mail;
return $this;
}
/**
* @return Collection<int, Cars>
*/
public function getAllCars(): Collection
{
return new ArrayCollection(array_merge($this->cars->toArray(), $this->contactCars->toArray()));
//return $this->cars;
}
/**
* @return Collection<int, Cars>
*/
public function getCars(): Collection
{
return $this->cars;
}
public function addCar(Cars $car): self
{
if (!$this->cars->contains($car)) {
$this->cars[] = $car;
$car->setOwners($this);
}
return $this;
}
public function removeCar(Cars $car): self
{
if ($this->cars->removeElement($car)) {
// set the owning side to null (unless already changed)
if ($car->getOwners() === $this) {
$car->setOwners(null);
}
}
return $this;
}
/**
* @return Collection<int, Cars>
*/
public function getContactCars(): Collection
{
return $this->contactCars;
}
public function addContactCar(Cars $car): self
{
if (!$this->cars->contains($car)) {
$this->contactCars[] = $car;
$car->setOwners($this);
}
return $this;
}
public function removeContactCar(Cars $car): self
{
if ($this->contactCars->removeElement($car)) {
// set the owning side to null (unless already changed)
if ($car->getOwners() === $this) {
$car->setOwners(null);
}
}
return $this;
}
public function __toString()
{
return $this->getName();
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getSearchFields(): ?string
{
return $this->name." | ".$this->address." | ".$this->mail." | ".$this->note;
}
}