src/Entity/CompanyClient.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyClientRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CompanyClientRepository::class)
  9.  */
  10. class CompanyClient
  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=9)
  24.      */
  25.     private $nif;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=false)
  28.      */
  29.     private $address;
  30.     /**
  31.      * @ORM\Column(type="string", length=510, nullable=true)
  32.      */
  33.     private $description;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=Company::class, inversedBy="companyClients")
  36.      * @ORM\JoinColumn(onDelete="CASCADE")
  37.      * @ORM\JoinColumn(nullable=false)
  38.      */
  39.     private $company;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity=Part::class, mappedBy="company_client")
  42.      */
  43.     private $parts;
  44.     /**
  45.      * @ORM\OneToOne(targetEntity=User::class, cascade={"persist", "remove"})
  46.      * @ORM\JoinColumn(onDelete="CASCADE")
  47.      * @ORM\JoinColumn(nullable=false)
  48.      */
  49.     private $user;
  50.     public function __construct()
  51.     {
  52.         $this->parts = 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 getNif(): ?string
  68.     {
  69.         return $this->nif;
  70.     }
  71.     public function setNif(string $nif): self
  72.     {
  73.         $this->nif $nif;
  74.         return $this;
  75.     }
  76.     public function getAddress(): ?string
  77.     {
  78.         return $this->address;
  79.     }
  80.     public function setAddress(string $address): self
  81.     {
  82.         $this->address $address;
  83.         return $this;
  84.     }
  85.     public function getDescription(): ?string
  86.     {
  87.         return $this->description;
  88.     }
  89.     public function setDescription(?string $description): self
  90.     {
  91.         $this->description $description;
  92.         return $this;
  93.     }
  94.     public function getCompany(): ?Company
  95.     {
  96.         return $this->company;
  97.     }
  98.     public function setCompany(?Company $company): self
  99.     {
  100.         $this->company $company;
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, Part>
  105.      */
  106.     public function getParts(): Collection
  107.     {
  108.         return $this->parts;
  109.     }
  110.     public function addPart(Part $part): self
  111.     {
  112.         if (!$this->parts->contains($part)) {
  113.             $this->parts[] = $part;
  114.             $part->setCompanyClient($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removePart(Part $part): self
  119.     {
  120.         if ($this->parts->removeElement($part)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($part->getCompanyClient() === $this) {
  123.                 $part->setCompanyClient(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     public function getUser(): User
  129.     {
  130.         return $this->user;
  131.     }
  132.     public function setUser(User $user): self
  133.     {
  134.         $this->user $user;
  135.         return $this;
  136.     }
  137. }