<?php
namespace App\Entity\BaseSite\Plan;
use App\Entity\BaseEntity;
use App\Repository\BaseSite\Plan\FeatureRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: FeatureRepository::class)]
class Feature extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?string $id;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(type: Types::BIGINT)]
private ?string $pricePerUnit = null;
#[ORM\Column(length: 255)]
private ?string $unit = null;
#[ORM\Column(type: Types::BIGINT)]
private ?string $pricePerExtraUnit = null;
#[ORM\OneToMany(mappedBy: 'feature', targetEntity: PlanFeature::class)]
private Collection $planFeatures;
#[ORM\OneToMany(mappedBy: 'feature', targetEntity: AddOn::class)]
private Collection $addOns;
#[ORM\Column(length: 255)]
private ?string $valueType = 'integer'; // یا 'boolean'
#[ORM\Column(length: 255)]
private ?string $featureKey = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $details = null;
public function __construct()
{
parent::__construct();
$this->planFeatures = new ArrayCollection();
$this->addOns = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getPricePerUnit(): ?string
{
return $this->pricePerUnit;
}
public function setPricePerUnit(string $pricePerUnit): static
{
$this->pricePerUnit = $pricePerUnit;
return $this;
}
public function getUnit(): ?string
{
return $this->unit;
}
public function setUnit(string $unit): static
{
$this->unit = $unit;
return $this;
}
public function getPricePerExtraUnit(): ?string
{
return $this->pricePerExtraUnit;
}
public function setPricePerExtraUnit(string $pricePerExtraUnit): static
{
$this->pricePerExtraUnit = $pricePerExtraUnit;
return $this;
}
/**
* @return Collection<int, PlanFeature>
*/
public function getPlanFeatures(): Collection
{
return $this->planFeatures;
}
public function addPlanFeature(PlanFeature $planFeature): static
{
if (!$this->planFeatures->contains($planFeature)) {
$this->planFeatures->add($planFeature);
$planFeature->setFeature($this);
}
return $this;
}
public function removePlanFeature(PlanFeature $planFeature): static
{
if ($this->planFeatures->removeElement($planFeature)) {
// set the owning side to null (unless already changed)
if ($planFeature->getFeature() === $this) {
$planFeature->setFeature(null);
}
}
return $this;
}
/**
* @return Collection<int, AddOn>
*/
public function getAddOns(): Collection
{
return $this->addOns;
}
public function addAddOn(AddOn $addOn): static
{
if (!$this->addOns->contains($addOn)) {
$this->addOns->add($addOn);
$addOn->setFeature($this);
}
return $this;
}
public function removeAddOn(AddOn $addOn): static
{
if ($this->addOns->removeElement($addOn)) {
// set the owning side to null (unless already changed)
if ($addOn->getFeature() === $this) {
$addOn->setFeature(null);
}
}
return $this;
}
public function getFeatureKey(): ?string
{
return $this->featureKey;
}
public function setFeatureKey(string $featureKey): static
{
$this->featureKey = $featureKey;
return $this;
}
public function getValueType(): ?string
{
return $this->valueType;
}
public function setValueType(?string $valueType): void
{
$this->valueType = $valueType;
}
public function getDetails(): ?string
{
return $this->details;
}
public function setDetails(?string $details): static
{
$this->details = $details;
return $this;
}
}