<?phpnamespace App\Entity\Product;use App\Repository\Product\ProductBoughtTogetherRepository;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: ProductBoughtTogetherRepository::class)]class ProductBoughtTogether{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'productBoughtTogethers')] private ?Product $product = null; #[ORM\ManyToOne(targetEntity: Product::class)] private ?Product $boughtWith = null; #[ORM\Column(type: 'integer')] private int $timesBoughtTogether = 1; #[ORM\Column(type: 'boolean')] private bool $isManual = false; #[ORM\Column(type: 'datetime_immutable')] private \DateTimeImmutable $createdAt; public function getId(): ?int { return $this->id; } public function getProduct(): ?Product { return $this->product; } public function setProduct(?Product $product): static { $this->product = $product; return $this; } public function getBoughtWith(): ?Product { return $this->boughtWith; } public function setBoughtWith(?Product $boughtWith): static { if ($this->product && $boughtWith && $this->product === $boughtWith) { throw new \InvalidArgumentException("Un produit ne peut pas être acheté avec lui-même."); } $this->boughtWith = $boughtWith; return $this; } public function getTimesBoughtTogether(): int { return $this->timesBoughtTogether; } public function setTimesBoughtTogether(int $timesBoughtTogether): static { if ($timesBoughtTogether < 1) { throw new \InvalidArgumentException("Le nombre de fois où les produits ont été achetés ensemble doit être au moins 1."); } $this->timesBoughtTogether = $timesBoughtTogether; return $this; } public function isManual(): bool { return $this->isManual; } public function setIsManual(bool $isManual): static { $this->isManual = $isManual; return $this; } public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): static { $this->createdAt = $createdAt; return $this; }}