src/Entity/Subscription.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\traits\base64Field;
  4. use App\Entity\traits\HasSlug;
  5. use App\Entity\traits\Timestapable;
  6. use App\Entity\traits\UniqueCode;
  7. use App\Repository\SubscriptionRepository;
  8. use Cocur\Slugify\Slugify;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  14. use Doctrine\ORM\Mapping\PrePersist;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ORM\Entity(repositoryClassSubscriptionRepository::class)]
  18. #[HasLifecycleCallbacks]
  19. class Subscription
  20. {
  21.     use Timestapable;
  22.     use base64Field;
  23.     use UniqueCode;
  24.     use HasSlug;
  25.     use Timestapable;
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column]
  29.     #[Groups(["show_subscription""user_info"])]
  30.     private ?int $id null;
  31.     #[ORM\Column(length255)]
  32.     // #[Assert\NotBlank(message: 'Ce champ est requis')]
  33.     #[Groups(["show_subscription""user_info"])]
  34.     private ?string $title null;
  35.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  36.     // #[Assert\NotBlank(message: 'Ce champ est requis')]
  37.     #[Groups(["show_subscription""user_info"])]
  38.     private ?string $description null;
  39.     #[ORM\Column(length255nullabletrue)]
  40.     #[Groups(["show_subscription""user_info"])]
  41.     private ?string $slug null;
  42.     #[ORM\Column(length255)]
  43.     #[Assert\NotBlank(message'Ce champ est requis')]
  44.     #[Groups(["show_subscription""user_info"])]
  45.     private ?string $price null;
  46.     #[ORM\Column(length255)]
  47.     #[Groups(["show_subscription""user_info"])]
  48.     private ?string $duration null;
  49.     #[ORM\Column(length255nullabletrue)]
  50.     #[Assert\NotBlank(message'Ce champ est requis')]
  51.     #[Groups(["show_subscription""user_info"])]
  52.     private ?string $currency_code null;
  53.     #[ORM\Column(length255)]
  54.     #[Assert\NotBlank(message'Ce champ est requis')]
  55.     #[Groups(["show_subscription""user_info"])]
  56.     private ?string $currency_name null;
  57.  
  58.     #[ORM\Column]
  59.     #[Groups(["show_subscription""user_info"])]
  60.     private ?bool $is_totally_free null;
  61.     #[ORM\ManyToOne(inversedBy'susbcription')]
  62.     #[Assert\NotBlank(message'Ce champ est requis')]
  63.     #[Groups(["show_subscription""user_info"])]
  64.     private ?SubscriptionType $subscriptionType null;
  65.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'subscriptions')]
  66.     #[Assert\NotBlank(message'Ce champ est requis')]
  67.     #[Groups(["show_subscription"])]
  68.     private Collection $subscriber;
  69.     #[ORM\ManyToOne(inversedBy'subscriptions')]
  70.     #[Groups(["show_subscription""user_info"])]
  71.     private ?SubscriptionFormula $subscriptionFormula null;
  72.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  73.     #[Groups(["show_subscription""user_info"])]
  74.     private ?\DateTimeInterface $startDate null;
  75.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  76.     #[Groups(["show_subscription""user_info"])]
  77.     private ?\DateTimeInterface $endDate null;
  78.     #[ORM\Column(length255options:["default"=> 1])]
  79.     private ?string $unit null;
  80.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  81.     #[Groups(["show_subscription""user_info"])]
  82.     private ?Order $commande null;
  83.     #[PrePersist]
  84.     public function generateSlug()
  85.     {
  86.         $this->slug = (new Slugify())->slugify($this->title);
  87.     }
  88.     public function __construct()
  89.     {
  90.         // $this->subscription = new ArrayCollection();
  91.         $this->subscriber = new ArrayCollection();
  92.     }
  93.     public function getId(): ?int
  94.     {
  95.         return $this->id;
  96.     }
  97.     public function getTitle(): ?string
  98.     {
  99.         return $this->title;
  100.     }
  101.     public function setTitle(string $title): self
  102.     {
  103.         $this->title $title;
  104.         return $this;
  105.     }
  106.     public function getDescription(): ?string
  107.     {
  108.         return $this->description;
  109.     }
  110.     public function setDescription(?string $description): self
  111.     {
  112.         $this->description $description;
  113.         return $this;
  114.     }
  115.     public function getSlug(): ?string
  116.     {
  117.         return $this->slug;
  118.     }
  119.     public function setSlug(?string $slug): self
  120.     {
  121.         $this->slug $slug;
  122.         return $this;
  123.     }
  124.     public function getPrice(): ?string
  125.     {
  126.         return $this->price;
  127.     }
  128.     public function setPrice(string $price): self
  129.     {
  130.         $this->price $price;
  131.         return $this;
  132.     }
  133.     public function getDuration(): ?string
  134.     {
  135.         return $this->duration;
  136.     }
  137.     public function setDuration(string $duration): self
  138.     {
  139.         $this->duration $duration;
  140.         return $this;
  141.     }
  142.     public function getCurrencyCode(): ?string
  143.     {
  144.         return $this->currency_code;
  145.     }
  146.     public function setCurrencyCode(?string $currency_code): self
  147.     {
  148.         $this->currency_code $currency_code;
  149.         return $this;
  150.     }
  151.     public function getCurrencyName(): ?string
  152.     {
  153.         return $this->currency_name;
  154.     }
  155.     public function setCurrencyName(string $currency_name): self
  156.     {
  157.         $this->currency_name $currency_name;
  158.         return $this;
  159.     }
  160.     public function isIsTotallyFree(): ?bool
  161.     {
  162.         return $this->is_totally_free;
  163.     }
  164.     public function setIsTotallyFree(bool $is_totally_free): self
  165.     {
  166.         $this->is_totally_free $is_totally_free;
  167.         return $this;
  168.     }
  169.     public function getSubscriptionType(): ?SubscriptionType
  170.     {
  171.         return $this->subscriptionType;
  172.     }
  173.     public function setSubscriptionType(?SubscriptionType $subscriptionType): self
  174.     {
  175.         $this->subscriptionType $subscriptionType;
  176.         return $this;
  177.     }
  178.     /**
  179.      * @return Collection<int, User>
  180.      */
  181.     public function getSubscriber(): Collection
  182.     {
  183.         return $this->subscriber;
  184.     }
  185.     public function addSubscriber(User $subscriber): self
  186.     {
  187.         if (!$this->subscriber->contains($subscriber)) {
  188.             $this->subscriber->add($subscriber);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeSubscriber(User $subscriber): self
  193.     {
  194.         $this->subscriber->removeElement($subscriber);
  195.         return $this;
  196.     }
  197.     public function getSubscriptionFormula(): ?SubscriptionFormula
  198.     {
  199.         return $this->subscriptionFormula;
  200.     }
  201.     public function setSubscriptionFormula(?SubscriptionFormula $subscriptionFormula): self
  202.     {
  203.         $this->subscriptionFormula $subscriptionFormula;
  204.         return $this;
  205.     }
  206.     public function getStartDate()
  207.     {
  208.         return $this->startDate;
  209.     }
  210.     public function setStartDate($startDate)
  211.     {
  212.         $this->startDate $startDate;
  213.         return $this;
  214.     }
  215.     public function getEndDate()
  216.     {
  217.         return $this->endDate;
  218.     }
  219.     public function setEndDate($endDate)
  220.     {
  221.         $this->endDate $endDate;
  222.         return $this;
  223.     }
  224.     public function getUnit(): ?string
  225.     {
  226.         return $this->unit;
  227.     }
  228.     public function setUnit(string $unit): self
  229.     {
  230.         $this->unit $unit;
  231.         return $this;
  232.     }
  233.     public function getCommande(): ?Order
  234.     {
  235.         return $this->commande;
  236.     }
  237.     public function setCommande(?Order $commande): self
  238.     {
  239.         $this->commande $commande;
  240.         return $this;
  241.     }
  242. }