src/Entity/ProductSubscriptionPrice.php line 8

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /** @ORM\Entity() @ORM\Table(name="product_subscription_price", uniqueConstraints={@ORM\UniqueConstraint(name="uniq_product_subscription_type", columns={"product_id", "subscription_type_id"})}) */
  5. class ProductSubscriptionPrice
  6. {
  7.     /** @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer") */
  8.     private ?int $id = null;
  9.     /** @ORM\ManyToOne(targetEntity=Product::class, inversedBy="subscriptionPrices") @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */
  10.     private ?Product $product = null;
  11.     /** @ORM\ManyToOne(targetEntity=SubscriptionType::class) @ORM\JoinColumn(nullable=false) */
  12.     private ?SubscriptionType $subscriptionType = null;
  13.     /** @ORM\Column(type="decimal", precision=10, scale=2) */
  14.     private string $price = '0.00';
  15.     /** @ORM\Column(type="integer", options={"default": 5}) */
  16.     private int $includedUsers = 5;
  17.     /** @ORM\Column(type="decimal", precision=10, scale=2, options={"default": 0}) */
  18.     private string $extraUserPrice = '0.00';
  19.     public function getId(): ?int { return $this->id; }
  20.     public function getProduct(): ?Product { return $this->product; }
  21.     public function setProduct(?Product $product): self { $this->product = $product; return $this; }
  22.     public function getSubscriptionType(): ?SubscriptionType { return $this->subscriptionType; }
  23.     public function setSubscriptionType(?SubscriptionType $type): self { $this->subscriptionType = $type; return $this; }
  24.     public function getPrice(): string { return $this->price; }
  25.     public function setPrice(string $price): self { $this->price = $price; return $this; }
  26.     public function getIncludedUsers(): int { return $this->includedUsers; }
  27.     public function setIncludedUsers(int $count): self { $this->includedUsers = max(1, $count); return $this; }
  28.     public function getExtraUserPrice(): string { return $this->extraUserPrice; }
  29.     public function setExtraUserPrice(string $price): self { $this->extraUserPrice = number_format(max(0, (float) $price), 2, '.', ''); return $this; }
  30. }