<?php
namespace App\Entity;
use App\Repository\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductRepository::class)]
class Product
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $category;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(type: 'float', nullable: true)]
private $price;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $glCode;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductPercentageSplit::class, cascade:['persist', 'remove'])]
private $percentageSplits;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: FilmProject::class)]
private $filmProjects;
#[ORM\Column(length: 255, nullable: true)]
private ?string $accountId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $refundCode = null;
#[ORM\OneToMany(mappedBy: 'recurringProduct', targetEntity: FilmProject::class)]
private Collection $recurringFilmProjects;
public function __construct()
{
$this->percentageSplits = new ArrayCollection();
$this->filmProjects = new ArrayCollection();
$this->recurringFilmProjects = 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 getCategory(): ?string
{
return $this->category;
}
public function setCategory(?string $category): self
{
$this->category = $category;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
public function getGlCode(): ?string
{
return $this->glCode;
}
public function setGlCode(?string $glCode): self
{
$this->glCode = $glCode;
return $this;
}
/**
* @return Collection<int, ProductPercentageSplit>
*/
public function getPercentageSplits(): Collection
{
return $this->percentageSplits;
}
public function addPercentageSplit(ProductPercentageSplit $percentageSplit): self
{
if (!$this->percentageSplits->contains($percentageSplit)) {
$this->percentageSplits[] = $percentageSplit;
$percentageSplit->setProduct($this);
}
return $this;
}
public function removePercentageSplit(ProductPercentageSplit $percentageSplit): self
{
if ($this->percentageSplits->removeElement($percentageSplit)) {
// set the owning side to null (unless already changed)
if ($percentageSplit->getProduct() === $this) {
$percentageSplit->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, FilmProject>
*/
public function getFilmProjects(): Collection
{
return $this->filmProjects;
}
public function addFilmProject(FilmProject $filmProject): self
{
if (!$this->filmProjects->contains($filmProject)) {
$this->filmProjects[] = $filmProject;
$filmProject->setProduct($this);
}
return $this;
}
public function removeFilmProject(FilmProject $filmProject): self
{
if ($this->filmProjects->removeElement($filmProject)) {
// set the owning side to null (unless already changed)
if ($filmProject->getProduct() === $this) {
$filmProject->setProduct(null);
}
}
return $this;
}
public function toString()
{
if ($this->name) {
return $this->name;
}
return 'Not set';
}
public function __toString()
{
return $this->toString();
}
public function getAccountId(): ?string
{
return $this->accountId;
}
public function setAccountId(?string $accountId): self
{
$this->accountId = $accountId;
return $this;
}
public function getRefundCode(): ?string
{
return $this->refundCode;
}
public function setRefundCode(?string $refundCode): static
{
$this->refundCode = $refundCode;
return $this;
}
/**
* @return Collection<int, FilmProject>
*/
public function getRecurringFilmProjects(): Collection
{
return $this->recurringFilmProjects;
}
public function addRecurringFilmProject(FilmProject $recurringFilmProject): static
{
if (!$this->recurringFilmProjects->contains($recurringFilmProject)) {
$this->recurringFilmProjects->add($recurringFilmProject);
$recurringFilmProject->setRecurringProduct($this);
}
return $this;
}
public function removeRecurringFilmProject(FilmProject $recurringFilmProject): static
{
if ($this->recurringFilmProjects->removeElement($recurringFilmProject)) {
// set the owning side to null (unless already changed)
if ($recurringFilmProject->getRecurringProduct() === $this) {
$recurringFilmProject->setRecurringProduct(null);
}
}
return $this;
}
}