src/Entity/Subscription.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\SubscriptionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassSubscriptionRepository::class)]
  10. #[ApiResource]
  11. class Subscription
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $title null;
  19.     #[ORM\Column(typeTypes::TEXT)]
  20.     private ?string $description null;
  21.     #[ORM\Column]
  22.     private ?float $cost null;
  23.     #[ORM\Column(length255)]
  24.     private ?string $cover_url null;
  25.     #[ORM\Column]
  26.     private ?int $duration null;
  27.     #[ORM\Column]
  28.     private ?\DateTimeImmutable $created_at null;
  29.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  30.     private ?\DateTimeInterface $updated_at null;
  31.     #[ORM\OneToMany(mappedBy'subscription'targetEntityUser::class)]
  32.     private Collection $pharmacy;
  33.     public function __construct()
  34.     {
  35.         $this->pharmacy = new ArrayCollection();
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getTitle(): ?string
  42.     {
  43.         return $this->title;
  44.     }
  45.     public function setTitle(string $title): static
  46.     {
  47.         $this->title $title;
  48.         return $this;
  49.     }
  50.     public function getDescription(): ?string
  51.     {
  52.         return $this->description;
  53.     }
  54.     public function setDescription(string $description): static
  55.     {
  56.         $this->description $description;
  57.         return $this;
  58.     }
  59.     public function getCost(): ?float
  60.     {
  61.         return $this->cost;
  62.     }
  63.     public function setCost(float $cost): static
  64.     {
  65.         $this->cost $cost;
  66.         return $this;
  67.     }
  68.     public function getCoverUrl(): ?string
  69.     {
  70.         return $this->cover_url;
  71.     }
  72.     public function setCoverUrl(string $cover_url): static
  73.     {
  74.         $this->cover_url $cover_url;
  75.         return $this;
  76.     }
  77.     public function getDuration(): ?int
  78.     {
  79.         return $this->duration;
  80.     }
  81.     public function setDuration(int $duration): static
  82.     {
  83.         $this->duration $duration;
  84.         return $this;
  85.     }
  86.     public function getCreatedAt(): ?\DateTimeImmutable
  87.     {
  88.         return $this->created_at;
  89.     }
  90.     public function setCreatedAt(\DateTimeImmutable $created_at): static
  91.     {
  92.         $this->created_at $created_at;
  93.         return $this;
  94.     }
  95.     public function getUpdatedAt(): ?\DateTimeInterface
  96.     {
  97.         return $this->updated_at;
  98.     }
  99.     public function setUpdatedAt(\DateTimeInterface $updated_at): static
  100.     {
  101.         $this->updated_at $updated_at;
  102.         return $this;
  103.     }
  104.     /**
  105.      * @return Collection<int, User>
  106.      */
  107.     public function getPharmacy(): Collection
  108.     {
  109.         return $this->pharmacy;
  110.     }
  111.     public function addPharmacy(User $pharmacy): static
  112.     {
  113.         if (!$this->pharmacy->contains($pharmacy)) {
  114.             $this->pharmacy->add($pharmacy);
  115.             $pharmacy->setSubscription($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removePharmacy(User $pharmacy): static
  120.     {
  121.         if ($this->pharmacy->removeElement($pharmacy)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($pharmacy->getSubscription() === $this) {
  124.                 $pharmacy->setSubscription(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129. }