<?php
namespace App\Entity;
use App\Repository\ProductElementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductElementRepository::class)]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: "dtype", type: "string")]
#[ORM\DiscriminatorMap(
[
'hotelRoomType' => HotelRoomType::class,
'partyZone' => PartyZone::class
]
)]
class ProductElement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'productElements')]
#[ORM\JoinColumn(nullable: false)]
private ?Product $product = null;
public function __construct()
{
}
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 getChildToString(): string
{
// Check if the child class has overridden the __toString method
if (method_exists($this, '__toString')) {
return $this->__toString();
} else {
return 'Default Child __toString: ' . $this->getId();
}
}
}