<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\SubscriptionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SubscriptionRepository::class)]
#[ApiResource]
class Subscription
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $description = null;
#[ORM\Column]
private ?float $cost = null;
#[ORM\Column(length: 255)]
private ?string $cover_url = null;
#[ORM\Column]
private ?int $duration = null;
#[ORM\Column]
private ?\DateTimeImmutable $created_at = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $updated_at = null;
#[ORM\OneToMany(mappedBy: 'subscription', targetEntity: User::class)]
private Collection $pharmacy;
public function __construct()
{
$this->pharmacy = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): static
{
$this->description = $description;
return $this;
}
public function getCost(): ?float
{
return $this->cost;
}
public function setCost(float $cost): static
{
$this->cost = $cost;
return $this;
}
public function getCoverUrl(): ?string
{
return $this->cover_url;
}
public function setCoverUrl(string $cover_url): static
{
$this->cover_url = $cover_url;
return $this;
}
public function getDuration(): ?int
{
return $this->duration;
}
public function setDuration(int $duration): static
{
$this->duration = $duration;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): static
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): static
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getPharmacy(): Collection
{
return $this->pharmacy;
}
public function addPharmacy(User $pharmacy): static
{
if (!$this->pharmacy->contains($pharmacy)) {
$this->pharmacy->add($pharmacy);
$pharmacy->setSubscription($this);
}
return $this;
}
public function removePharmacy(User $pharmacy): static
{
if ($this->pharmacy->removeElement($pharmacy)) {
// set the owning side to null (unless already changed)
if ($pharmacy->getSubscription() === $this) {
$pharmacy->setSubscription(null);
}
}
return $this;
}
}