src/Entity/Plan.php line 14
<?phpnamespace App\Entity;use App\Enum\RuleType;use App\Repository\PlanRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Gedmo\Timestampable\Traits\TimestampableEntity;#[ORM\Entity(repositoryClass: PlanRepository::class)]class Plan{use TimestampableEntity;#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(length: 255, nullable: true)]private ?string $description = null;#[ORM\ManyToOne(inversedBy: 'plans', fetch: 'EAGER')]private ?Period $period = null;#[ORM\ManyToMany(targetEntity: Rule::class, inversedBy: 'plans')]private Collection $rules;#[ORM\OneToMany(mappedBy: 'plan', targetEntity: PlanAssignment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]private Collection $planAssignments;/* #[ORM\ManyToMany(targetEntity: Rule::class)]private Collection $creditRules;#[ORM\ManyToMany(targetEntity: Rule::class)]private Collection $commissionRules;*/public function __construct(){$this->rules = new ArrayCollection();$this->creditRules = new ArrayCollection();$this->commissionRules = new ArrayCollection();$this->planAssignments = 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 getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getPeriod(): ?Period{return $this->period;}public function setPeriod(?Period $period): self{$this->period = $period;return $this;}/*** @return Collection<int, Rule>*/public function getRules(): Collection{return $this->rules;}public function addRule(Rule $rule): static{if (!$this->rules->contains($rule)) {$this->rules->add($rule);}return $this;}public function removeRule(Rule $rule): static{$this->rules->removeElement($rule);return $this;}/*** @return Collection<int, Rule>*/public function getCreditRules(): Collection{return $this->rules->filter(function (Rule $rule) {return in_array($rule->getType(), [RuleType::DIRECT_RULE, RuleType::INDIRECT_RULE]);});}/*** @return Collection<int, Rule>*/public function getDirectCreditRules(): Collection{return $this->rules->filter(function (Rule $rule) {return $rule->getType() == RuleType::DIRECT_RULE;});}/*** @return Collection<int, Rule>*/public function getInDirectCreditRules(): Collection{return $this->rules->filter(function (Rule $rule) {return $rule->getType() == RuleType::INDIRECT_RULE;});}/*** @return Collection<int, Rule>*/public function getCommissionRules(): Collection{return $this->rules->filter(function (Rule $rule) {return $rule->getType() == RuleType::COMMISSION_RULE;});}public function addCreditRule(Rule $rule): static{if (!$this->rules->contains($rule)) {$this->rules->add($rule);}return $this;}public function removeCreditRule(Rule $rule): static{$this->rules->removeElement($rule);return $this;}/*public function getCommissionRules(): Collection{return $this->rules;}*/public function addCommissionRule(Rule $rule): static{if (!$this->rules->contains($rule)) {$this->rules->add($rule);}return $this;}public function removeCommissionRule(Rule $rule): static{$this->rules->removeElement($rule);return $this;}public function __toString(){return $this->name;}/*** @return Collection<int, PlanAssignment>*/public function getPlanAssignments(): Collection{return $this->planAssignments;}public function addPlanAssignment(PlanAssignment $planAssignment): static{if (!$this->planAssignments->contains($planAssignment)) {$this->planAssignments->add($planAssignment);$planAssignment->setPlan($this);}return $this;}public function removePlanAssignment(PlanAssignment $planAssignment): static{if ($this->planAssignments->removeElement($planAssignment)) {// set the owning side to null (unless already changed)if ($planAssignment->getPlan() === $this) {$planAssignment->setPlan(null);}}return $this;}}