src/Entity/Operator.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\ActiveConstants;
  4. use App\Constants\OperatorTypeConstants;
  5. use App\Repository\OperatorRepository;
  6. use App\Traits\ActivityTrait;
  7. use App\Traits\TimeTrackTrait;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\DBAL\Types\Types;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. #[ORM\Entity(repositoryClassOperatorRepository::class)]
  15. #[ORM\HasLifecycleCallbacks]
  16. #[UniqueEntity(fields: ['type'])]
  17. class Operator
  18. {
  19.     use TimeTrackTrait;
  20.     use ActivityTrait;
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     private ?int $id null;
  25.     #[ORM\Column(length191nullabletrue)]
  26.     private ?string $name null;
  27.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  28.     private ?string $description null;
  29.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  30.     private ?string $topUpLink null;
  31.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  32.     private ?string $priceText null;
  33.     #[ORM\ManyToMany(targetEntity"App\Entity\Company"inversedBy'operators'cascade: ['persist'], orphanRemovalfalse)]
  34.     #[ORM\JoinTable(name'operators_companies')]
  35.     #[ORM\JoinColumn(name'operator_id'referencedColumnName'id'onDelete'CASCADE')]
  36.     #[ORM\InverseJoinColumn(name'company_id'referencedColumnName'id'onDelete'CASCADE')]
  37.     private $companies;
  38.     #[ORM\OneToMany(mappedBy'operator'targetEntityPhoneNumber::class, orphanRemovaltrue)]
  39.     private Collection $phoneNumbers;
  40.     #[ORM\OneToMany(mappedBy'operator'targetEntityTariff::class, orphanRemovaltrue)]
  41.     private Collection $tariffs;
  42.     /**
  43.      * @var string
  44.      */
  45.     #[ORM\Column(name'slug'type'string'length191uniquetruenullabletrue)]
  46.     #[Gedmo\Slug(fields: ['name'], updatablefalse)]
  47.     private $slug;
  48.     #[ORM\Column(type'integer'length11)]
  49.     private $type;
  50.     #[ORM\Column(type'integer'length11nullabletrue)]
  51.     private ?int $minNumberQty;
  52.     #[ORM\Column(name'position'type'integer'nullabletrueoptions: ['unsigned' => true])]
  53.     #[Gedmo\SortablePosition]
  54.     private ?int $position 1;
  55.     #[ORM\Column(type'integer'options: ['default' => 5])]
  56.     private int $purchaseLimit 5;
  57.     #[ORM\OneToMany(mappedBy'operator'targetEntityFaqQuestion::class, orphanRemovalfalse)]
  58.     private Collection $faqQuestions;
  59.     #[ORM\Column(type'boolean'options: ['default' => true])]
  60.     private $isServerActive true;
  61.     #[ORM\Column(type'text'nullabletrue)]
  62.     private $inactiveText;
  63.     private bool $connectionError false;
  64.     public function isServerActive(): ?bool
  65.     {
  66.         return $this->isServerActive;
  67.     }
  68.     public function setIsServerActive(bool $isServerActive): self
  69.     {
  70.         $this->isServerActive $isServerActive;
  71.         return $this;
  72.     }
  73.     public function getInactiveText(): ?string
  74.     {
  75.         return $this->inactiveText;
  76.     }
  77.     public function setInactiveText(?string $inactiveText): self
  78.     {
  79.         $this->inactiveText $inactiveText;
  80.         return $this;
  81.     }
  82.     public function __construct()
  83.     {
  84.         $this->companies = new ArrayCollection();
  85.         $this->phoneNumbers = new ArrayCollection();
  86.         $this->tariffs = new ArrayCollection();
  87.         $this->faqQuestions = new ArrayCollection();
  88.     }
  89.     public function setConnectionError(bool $connectionError): static
  90.     {
  91.         $this->connectionError $connectionError;
  92.         return $this;
  93.     }
  94.     public function getConnectionError(): bool
  95.     {
  96.         return $this->connectionError;
  97.     }
  98.     public function __toString()
  99.     {
  100.         return $this->getName();
  101.     }
  102.     public function getId(): ?int
  103.     {
  104.         return $this->id;
  105.     }
  106.     public function getName(): ?string
  107.     {
  108.         return $this->name;
  109.     }
  110.     public function setName(?string $name): static
  111.     {
  112.         $this->name $name;
  113.         return $this;
  114.     }
  115.     /**
  116.      * Set createdAt.
  117.      *
  118.      * @param \DateTime|null $createdAt
  119.      *
  120.      * @return Operator
  121.      */
  122.     public function setCreatedAt($createdAt null)
  123.     {
  124.         $this->createdAt $createdAt;
  125.         return $this;
  126.     }
  127.     /**
  128.      * Get createdAt.
  129.      *
  130.      * @return \DateTime|null
  131.      */
  132.     public function getCreatedAt()
  133.     {
  134.         return $this->createdAt;
  135.     }
  136.     /**
  137.      * Set updatedAt.
  138.      *
  139.      * @param \DateTime|null $updatedAt
  140.      *
  141.      * @return Operator
  142.      */
  143.     public function setUpdatedAt($updatedAt null)
  144.     {
  145.         $this->updatedAt $updatedAt;
  146.         return $this;
  147.     }
  148.     /**
  149.      * Get updatedAt.
  150.      *
  151.      * @return \DateTime|null
  152.      */
  153.     public function getUpdatedAt()
  154.     {
  155.         return $this->updatedAt;
  156.     }
  157.     /**
  158.      * Set active.
  159.      *
  160.      * @param int $active
  161.      *
  162.      * @return Operator
  163.      */
  164.     public function setActive($active)
  165.     {
  166.         $this->active $active;
  167.         return $this;
  168.     }
  169.     /**
  170.      * Get active.
  171.      *
  172.      * @return int
  173.      */
  174.     public function getActive()
  175.     {
  176.         return $this->active;
  177.     }
  178.     /**
  179.      * @return Collection<int, Company>
  180.      */
  181.     public function getCompanies(): Collection
  182.     {
  183.         return $this->companies;
  184.     }
  185.     public function addCompany(Company $company): static
  186.     {
  187.         if (!$this->companies->contains($company)) {
  188.             $this->companies->add($company);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeCompany(Company $company): static
  193.     {
  194.         $this->companies->removeElement($company);
  195.         return $this;
  196.     }
  197.     /**
  198.      * @return Collection<int, PhoneNumber>
  199.      */
  200.     public function getPhoneNumbers(): Collection
  201.     {
  202.         return $this->phoneNumbers;
  203.     }
  204.     public function addPhoneNumber(PhoneNumber $phoneNumber): static
  205.     {
  206.         if (!$this->phoneNumbers->contains($phoneNumber)) {
  207.             $this->phoneNumbers->add($phoneNumber);
  208.             $phoneNumber->setOperator($this);
  209.         }
  210.         return $this;
  211.     }
  212.     public function removePhoneNumber(PhoneNumber $phoneNumber): static
  213.     {
  214.         if ($this->phoneNumbers->removeElement($phoneNumber)) {
  215.             // set the owning side to null (unless already changed)
  216.             if ($phoneNumber->getOperator() === $this) {
  217.                 $phoneNumber->setOperator(null);
  218.             }
  219.         }
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection<int, Tariff>
  224.      */
  225.     public function getTariffs(): Collection
  226.     {
  227.         return $this->tariffs;
  228.     }
  229.     public function addTariff(Tariff $tariff): static
  230.     {
  231.         if (!$this->tariffs->contains($tariff)) {
  232.             $this->tariffs->add($tariff);
  233.             $tariff->setOperator($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeTariff(Tariff $tariff): static
  238.     {
  239.         if ($this->tariffs->removeElement($tariff)) {
  240.             // set the owning side to null (unless already changed)
  241.             if ($tariff->getOperator() === $this) {
  242.                 $tariff->setOperator(null);
  243.             }
  244.         }
  245.         return $this;
  246.     }
  247.     public function getSlug(): ?string
  248.     {
  249.         return $this->slug;
  250.     }
  251.     public function setSlug(?string $slug): static
  252.     {
  253.         $this->slug $slug;
  254.         return $this;
  255.     }
  256.     public function getType(): ?int
  257.     {
  258.         return $this->type;
  259.     }
  260.     public function setType(int $type): static
  261.     {
  262.         $this->type $type;
  263.         return $this;
  264.     }
  265.     public function getTypeLabel(): string
  266.     {
  267.         $types OperatorTypeConstants::getTranslatedValues();
  268.         return $types[$this->type] ?? (string)$this->type;
  269.     }
  270.     public function getActiveLabel(): string
  271.     {
  272.         return (isset($this->active) && $this->active) ? ActiveConstants::LABEL_YES ActiveConstants::LABEL_NO;
  273.     }
  274.     public function getIsServerActiveLabel(): string
  275.     {
  276.         return $this->isServerActive ActiveConstants::LABEL_YES ActiveConstants::LABEL_NO;
  277.     }
  278.     public function getDescription(): ?string
  279.     {
  280.         return $this->description;
  281.     }
  282.     public function setDescription(?string $description): static
  283.     {
  284.         $this->description $description;
  285.         return $this;
  286.     }
  287.     public function getTopUpLink(): ?string
  288.     {
  289.         return $this->topUpLink;
  290.     }
  291.     public function setTopUpLink(?string $topUpLink): static
  292.     {
  293.         $this->topUpLink $topUpLink;
  294.         return $this;
  295.     }
  296.     public function getPosition(): ?int
  297.     {
  298.         return $this->position;
  299.     }
  300.     public function setPosition(?int $position): static
  301.     {
  302.         $this->position $position;
  303.         return $this;
  304.     }
  305.     public function getPriceText(): ?string
  306.     {
  307.         return $this->priceText;
  308.     }
  309.     public function setPriceText(?string $priceText): static
  310.     {
  311.         $this->priceText $priceText;
  312.         return $this;
  313.     }
  314.     public function getMinNumberQty(): ?int
  315.     {
  316.         return $this->minNumberQty;
  317.     }
  318.     public function setMinNumberQty(?int $minNumberQty): static
  319.     {
  320.         $this->minNumberQty $minNumberQty;
  321.         return $this;
  322.     }
  323.     /**
  324.      * @return Collection<int, FaqQuestion>
  325.      */
  326.     public function getFaqQuestions(): Collection
  327.     {
  328.         return $this->faqQuestions;
  329.     }
  330.     public function addFaqQuestion(FaqQuestion $faqQuestion): static
  331.     {
  332.         if (!$this->faqQuestions->contains($faqQuestion)) {
  333.             $this->faqQuestions->add($faqQuestion);
  334.             $faqQuestion->setOperator($this);
  335.         }
  336.         return $this;
  337.     }
  338.     public function removeFaqQuestion(FaqQuestion $faqQuestion): static
  339.     {
  340.         if ($this->faqQuestions->removeElement($faqQuestion)) {
  341.             // set the owning side to null (unless already changed)
  342.             if ($faqQuestion->getOperator() === $this) {
  343.                 $faqQuestion->setOperator(null);
  344.             }
  345.         }
  346.         return $this;
  347.     }
  348.     public function getPurchaseLimit(): int
  349.     {
  350.         return $this->purchaseLimit;
  351.     }
  352.     public function setPurchaseLimit(int $purchaseLimit): self
  353.     {
  354.         $this->purchaseLimit $purchaseLimit;
  355.         return $this;
  356.     }
  357. }