<?php
namespace App\Entity;
use App\Repository\SponsorRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: SponsorRepository::class)]
class Sponsor
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'uuid', unique: true)]
private ?string $uuid = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private ?Person $person = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private ?Address $address = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: false)]
private ?Contact $contact = null;
#[ORM\OneToMany(mappedBy: 'sponsor', targetEntity: CustomerAdvertisingArea::class, cascade: ['persist'])]
private Collection $areas;
#[ORM\ManyToOne(targetEntity: Customer::class, inversedBy: 'sponsor')]
#[ORM\JoinColumn(name: 'fk_customer', nullable: false)]
private ?Customer $customer = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\OneToMany(mappedBy: 'sponsor', targetEntity: Contract::class, cascade: ['persist', 'remove'])]
#[ORM\OrderBy(["id" => "DESC"])]
private ?Collection $contracts;
#[ORM\ManyToOne(cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(nullable: true)]
private ?Image $image = null;
public function __construct()
{
$this->areas = new ArrayCollection();
$this->contracts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getPerson(): ?Person
{
return $this->person;
}
public function setPerson(Person $person): self
{
$this->person = $person;
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(Address $address): self
{
$this->address = $address;
return $this;
}
public function getContact(): ?Contact
{
return $this->contact;
}
public function setContact(Contact $contact): self
{
$this->contact = $contact;
return $this;
}
/**
* @return Collection<int, CustomerAdvertisingArea>
*/
public function getAreas(): Collection
{
return $this->areas;
}
public function addCustomerAdvertisingArea(CustomerAdvertisingArea $customerAdvertisingArea): self
{
if (!$this->areas->contains($customerAdvertisingArea)) {
$this->areas->add($customerAdvertisingArea);
$customerAdvertisingArea->setSponsor($this);
}
return $this;
}
public function removeCustomerAdvertisingArea(CustomerAdvertisingArea $customerAdvertisingArea): self
{
if ($this->areas->removeElement($customerAdvertisingArea)) {
// set the owning side to null (unless already changed)
if ($customerAdvertisingArea->getSponsor() === $this) {
$customerAdvertisingArea->setSponsor(null);
}
}
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
/**
* @return Collection<int, Contract>
*/
public function getContracts(): Collection
{
return $this->contracts;
}
public function addContract(Contract $contract): self
{
if (!$this->contracts->contains($contract)) {
$this->contracts->add($contract);
$contract->setSponsor($this);
}
return $this;
}
public function removeContract(Contract $contract): self
{
if ($this->contracts->removeElement($contract)) {
// set the owning side to null (unless already changed)
if ($contract->getSponsor() === $this) {
$contract->setSponsor(null);
}
}
return $this;
}
public function getImage(): ?Image
{
return $this->image;
}
public function setImage(?Image $image): self
{
$this->image = $image;
return $this;
}
public function addArea(CustomerAdvertisingArea $area): self
{
if (!$this->areas->contains($area)) {
$this->areas->add($area);
$area->setSponsor($this);
}
return $this;
}
public function removeArea(CustomerAdvertisingArea $area): self
{
if ($this->areas->removeElement($area)) {
// set the owning side to null (unless already changed)
if ($area->getSponsor() === $this) {
$area->setSponsor(null);
}
}
return $this;
}
public function getUuid(): ?string
{
return $this->uuid;
}
public function setUuid(Uuid $uuid): self
{
$this->uuid = $uuid;
return $this;
}
}