<?php
namespace App\Entity;
use App\Repository\BPModelRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Dompdf\FrameReflower\Page;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass=BPModelRepository::class)
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @UniqueEntity(
* fields={"name"},
* errorPath="name",
* message="Un business plan existe avec le même nom"
* )
*/
class BPModel extends BaseEntity
{
use SoftDeleteableEntity;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=191, unique=true)
*/
private $name;
/**
* @ORM\Column(type="integer")
*/
private $variableNumber;
/**
* @ORM\OneToOne(targetEntity=Variable::class, cascade={"persist", "remove"})
*/
private $variable;
/**
* @ORM\OneToOne(targetEntity=FileManager::class, cascade={"persist", "remove"})
*/
private $modelFile;
/**
* @ORM\OneToMany(targetEntity=BPModelRole::class, mappedBy="bpModel")
*/
private $bPModelRoles;
/**
* @ORM\OneToMany(targetEntity=Variable::class, mappedBy="bPModel", cascade={"persist", "remove"})
*/
private $variables;
/**
* @ORM\OneToMany(targetEntity=CustomerBP::class, mappedBy="bpModel", cascade={"persist", "remove"})
*/
private $customerBPs;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(length=191)
*/
private $slug;
/**
* @ORM\OneToOne(targetEntity=ImageManager::class, cascade={"persist", "remove"})
*/
private $thumbnail;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $reference;
/**
* @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
*/
private $price;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $numberOfPage;
/**
* @ORM\OneToMany(targetEntity=PayPage::class, mappedBy="bpModel", cascade={"persist", "remove"})
*/
private $payPages;
/**
* @ORM\ManyToOne(targetEntity=BpCategory::class, inversedBy="BpModel")
*/
private $bpCategory;
/**
* @ORM\ManyToMany(targetEntity=User::class, inversedBy="bpModels")
*/
private $customers;
public function __construct()
{
$this->bPModelRoles = new ArrayCollection();
$this->variables = new ArrayCollection();
$this->customerBPs = new ArrayCollection();
$this->payPages = new ArrayCollection();
$this->customers = 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 getVariableNumber(): ?int
{
return $this->variableNumber;
}
public function setVariableNumber(int $variableNumber): self
{
$this->variableNumber = $variableNumber;
return $this;
}
public function getVariable(): ?Variable
{
return $this->variable;
}
public function setVariable(?Variable $variable): self
{
$this->variable = $variable;
return $this;
}
public function getModelFile(): ?FileManager
{
return $this->modelFile;
}
public function setModelFile(?FileManager $modelFile): self
{
$this->modelFile = $modelFile;
return $this;
}
/**
* @return Collection<int, BPModelRole>
*/
public function getBPModelRoles(): Collection
{
return $this->bPModelRoles;
}
public function addBPModelRole(BPModelRole $bPModelRole): self
{
if (!$this->bPModelRoles->contains($bPModelRole)) {
$this->bPModelRoles[] = $bPModelRole;
$bPModelRole->setBpModel($this);
}
return $this;
}
public function removeBPModelRole(BPModelRole $bPModelRole): self
{
if ($this->bPModelRoles->removeElement($bPModelRole)) {
// set the owning side to null (unless already changed)
if ($bPModelRole->getBpModel() === $this) {
$bPModelRole->setBpModel(null);
}
}
return $this;
}
/**
* @return Collection<int, Variable>
*/
public function getVariables(): Collection
{
return $this->variables;
}
public function addVariable(Variable $variable): self
{
if (!$this->variables->contains($variable)) {
$this->variables[] = $variable;
$variable->setBPModel($this);
}
return $this;
}
public function removeVariable(Variable $variable): self
{
if ($this->variables->removeElement($variable)) {
// set the owning side to null (unless already changed)
if ($variable->getBPModel() === $this) {
$variable->setBPModel(null);
}
}
return $this;
}
/**
* @return Collection<int, CustomerBP>
*/
public function getCustomerBPs(): Collection
{
return $this->customerBPs;
}
public function addCustomerBP(CustomerBP $customerBP): self
{
if (!$this->customerBPs->contains($customerBP)) {
$this->customerBPs[] = $customerBP;
$customerBP->setBpModel($this);
}
return $this;
}
public function removeCustomerBP(CustomerBP $customerBP): self
{
if ($this->customerBPs->removeElement($customerBP)) {
// set the owning side to null (unless already changed)
if ($customerBP->getBpModel() === $this) {
$customerBP->setBpModel(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getThumbnail(): ?ImageManager
{
return $this->thumbnail;
}
public function setThumbnail(?ImageManager $thumbnail): self
{
$this->thumbnail = $thumbnail;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(?string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getPrice(): ?string
{
return $this->price;
}
public function setPrice(?string $price): self
{
$this->price = $price;
return $this;
}
public function getNumberOfPage(): ?int
{
return $this->numberOfPage;
}
public function setNumberOfPage(?int $numberOfPage): self
{
$this->numberOfPage = $numberOfPage;
return $this;
}
/**
* @return Collection<int, PayPage>
*/
public function getPayPages(): Collection
{
return $this->payPages;
}
public function addPayPage(PayPage $payPage): self
{
if (!$this->payPages->contains($payPage)) {
$this->payPages[] = $payPage;
$payPage->setBpModel($this);
}
return $this;
}
public function removePayPage(PayPage $payPage): self
{
if ($this->payPages->removeElement($payPage)) {
// set the owning side to null (unless already changed)
if ($payPage->getBpModel() === $this) {
$payPage->setBpModel(null);
}
}
return $this;
}
public function getBpCategory(): ?BpCategory
{
return $this->bpCategory;
}
public function setBpCategory(?BpCategory $bpCategory): self
{
$this->bpCategory = $bpCategory;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(User $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers[] = $customer;
}
return $this;
}
public function removeCustomer(User $customer): self
{
$this->customers->removeElement($customer);
return $this;
}
}