<?phpnamespace App\Entity;use App\Repository\CategoryRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Doctrine\Common\Collections\Collection; // 追加use Doctrine\Common\Collections\ArrayCollection; // 追加#[ORM\Entity(repositoryClass: CategoryRepository::class)]#[ORM\Table(name: "dtb_category")] // ec-cube側のテーブル名を指定class Category{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; // #[ORM\OneToMany(targetEntity: ProductCategory::class, mappedBy: 'product')] #[ORM\OneToMany(targetEntity: ProductCategory::class, mappedBy: 'category')] private Collection $productCategories; public function __construct() { $this->productCategories = new ArrayCollection(); } // /** // * Categoryを取得するためのメソッド // */ // public function getCategories(): Collection // { // return $this->productCategories->map(fn(ProductCategory $pc) => $pc->getCategory()); // } /** * Productを取得するためのメソッド */ public function getProducts(): Collection { return $this->productCategories->map(fn(ProductCategory $pc) => $pc->getProduct()); } #[ORM\Column(nullable: true)] private ?int $parent_category_id = null; #[ORM\Column(nullable: true)] private ?int $creator_id = null; #[ORM\Column(length: 255)] private ?string $category_name = null; #[ORM\Column] private ?int $hierarchy = null; #[ORM\Column] private ?int $sort_no = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $create_date = null; #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $update_date = null; #[ORM\Column(length: 255)] private ?string $discriminator_type = null; public function getId(): ?int { return $this->id; } public function getParentCategoryId(): ?int { return $this->parent_category_id; } public function setParentCategoryId(?int $parent_category_id): static { $this->parent_category_id = $parent_category_id; return $this; } public function getCreatorId(): ?int { return $this->creator_id; } public function setCreatorId(?int $creator_id): static { $this->creator_id = $creator_id; return $this; } public function getCategoryName(): ?string { return $this->category_name; } public function setCategoryName(string $category_name): static { $this->category_name = $category_name; return $this; } public function getHierarchy(): ?int { return $this->hierarchy; } public function setHierarchy(int $hierarchy): static { $this->hierarchy = $hierarchy; return $this; } public function getSortNo(): ?int { return $this->sort_no; } public function setSortNo(int $sort_no): static { $this->sort_no = $sort_no; return $this; } public function getCreateDate(): ?\DateTimeInterface { return $this->create_date; } public function setCreateDate(\DateTimeInterface $create_date): static { $this->create_date = $create_date; return $this; } public function getUpdateDate(): ?\DateTimeInterface { return $this->update_date; } public function setUpdateDate(\DateTimeInterface $update_date): static { $this->update_date = $update_date; return $this; } public function getDiscriminatorType(): ?string { return $this->discriminator_type; } public function setDiscriminatorType(string $discriminator_type): static { $this->discriminator_type = $discriminator_type; return $this; }}