<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/** @ORM\Entity() @ORM\Table(name="product_subscription_price", uniqueConstraints={@ORM\UniqueConstraint(name="uniq_product_subscription_type", columns={"product_id", "subscription_type_id"})}) */
class ProductSubscriptionPrice
{
/** @ORM\Id @ORM\GeneratedValue @ORM\Column(type="integer") */
private ?int $id = null;
/** @ORM\ManyToOne(targetEntity=Product::class, inversedBy="subscriptionPrices") @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */
private ?Product $product = null;
/** @ORM\ManyToOne(targetEntity=SubscriptionType::class) @ORM\JoinColumn(nullable=false) */
private ?SubscriptionType $subscriptionType = null;
/** @ORM\Column(type="decimal", precision=10, scale=2) */
private string $price = '0.00';
/** @ORM\Column(type="integer", options={"default": 5}) */
private int $includedUsers = 5;
/** @ORM\Column(type="decimal", precision=10, scale=2, options={"default": 0}) */
private string $extraUserPrice = '0.00';
public function getId(): ?int { return $this->id; }
public function getProduct(): ?Product { return $this->product; }
public function setProduct(?Product $product): self { $this->product = $product; return $this; }
public function getSubscriptionType(): ?SubscriptionType { return $this->subscriptionType; }
public function setSubscriptionType(?SubscriptionType $type): self { $this->subscriptionType = $type; return $this; }
public function getPrice(): string { return $this->price; }
public function setPrice(string $price): self { $this->price = $price; return $this; }
public function getIncludedUsers(): int { return $this->includedUsers; }
public function setIncludedUsers(int $count): self { $this->includedUsers = max(1, $count); return $this; }
public function getExtraUserPrice(): string { return $this->extraUserPrice; }
public function setExtraUserPrice(string $price): self { $this->extraUserPrice = number_format(max(0, (float) $price), 2, '.', ''); return $this; }
}