<?php
namespace App\Entity;
use App\Repository\CompanyClientRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CompanyClientRepository::class)
*/
class CompanyClient
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=9)
*/
private $nif;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private $address;
/**
* @ORM\Column(type="string", length=510, nullable=true)
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity=Company::class, inversedBy="companyClients")
* @ORM\JoinColumn(onDelete="CASCADE")
* @ORM\JoinColumn(nullable=false)
*/
private $company;
/**
* @ORM\OneToMany(targetEntity=Part::class, mappedBy="company_client")
*/
private $parts;
/**
* @ORM\OneToOne(targetEntity=User::class, cascade={"persist", "remove"})
* @ORM\JoinColumn(onDelete="CASCADE")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
public function __construct()
{
$this->parts = 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 getNif(): ?string
{
return $this->nif;
}
public function setNif(string $nif): self
{
$this->nif = $nif;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
/**
* @return Collection<int, Part>
*/
public function getParts(): Collection
{
return $this->parts;
}
public function addPart(Part $part): self
{
if (!$this->parts->contains($part)) {
$this->parts[] = $part;
$part->setCompanyClient($this);
}
return $this;
}
public function removePart(Part $part): self
{
if ($this->parts->removeElement($part)) {
// set the owning side to null (unless already changed)
if ($part->getCompanyClient() === $this) {
$part->setCompanyClient(null);
}
}
return $this;
}
public function getUser(): User
{
return $this->user;
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
}