<?phpnamespace Roothirsch\Tuer24Bundle\Entity;use Doctrine\ORM\Mapping as ORM;use Roothirsch\Tuer24Bundle\Repository\Tuer24CartItemRepository;#[ORM\Entity(repositoryClass: "Roothirsch\Tuer24Bundle\Repository\Tuer24CartItemRepository")]#[ORM\Table(name: 'roothirsch_tuer24_cart_item')]#[ORM\HasLifecycleCallbacks]class Tuer24CartItem{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'items')] #[ORM\JoinColumn(nullable: false)] private ?Tuer24Cart $cart = null; #[ORM\Column] private ?int $productId = null; #[ORM\Column(length: 255)] private ?string $productSku = null; #[ORM\Column(length: 255)] private ?string $productName = null; #[ORM\Column] private ?float $price = null; #[ORM\Column] private ?int $quantity = null; #[ORM\Column(nullable: true)] private ?float $discountPercent = null; #[ORM\Column] private ?\DateTimeImmutable $createdAt = null; #[ORM\Column] private ?\DateTimeImmutable $updatedAt = null; public function __construct() { $this->createdAt = new \DateTimeImmutable(); $this->updatedAt = new \DateTimeImmutable(); $this->quantity = 1; } #[ORM\PreUpdate] public function preUpdate(): void { $this->updatedAt = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getCart(): ?Tuer24Cart { return $this->cart; } public function setCart(?Tuer24Cart $cart): self { $this->cart = $cart; return $this; } public function getProductId(): ?int { return $this->productId; } public function setProductId(int $productId): self { $this->productId = $productId; return $this; } public function getProductSku(): ?string { return $this->productSku; } public function setProductSku(string $productSku): self { $this->productSku = $productSku; return $this; } public function getProductName(): ?string { return $this->productName; } public function setProductName(string $productName): self { $this->productName = $productName; return $this; } public function getPrice(): ?float { return $this->price; } public function setPrice(float $price): self { $this->price = $price; return $this; } public function getQuantity(): ?int { return $this->quantity; } public function setQuantity(int $quantity): self { $this->quantity = $quantity; return $this; } public function getDiscountPercent(): ?float { return $this->discountPercent; } public function setDiscountPercent(?float $discountPercent): self { $this->discountPercent = $discountPercent; return $this; } public function getDiscountAmount(): float { if ($this->discountPercent === null || $this->discountPercent <= 0) { return 0; } return $this->price * ($this->discountPercent / 100) * $this->quantity; } public function getSubtotal(): float { return $this->price * $this->quantity; } public function getTotal(): float { return $this->getSubtotal() - $this->getDiscountAmount(); } public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): self { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeImmutable { return $this->updatedAt; } public function setUpdatedAt(\DateTimeImmutable $updatedAt): self { $this->updatedAt = $updatedAt; return $this; }}