Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active July 13, 2021 06:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/c0febeeee355cf49a5d57df95284a350 to your computer and use it in GitHub Desktop.
Save kurozumi/c0febeeee355cf49a5d57df95284a350 to your computer and use it in GitHub Desktop.
Productエンティティに自動登録する会員グループを保存する項目を追加
<?php
/**
* This file is part of CustomerGroupProduct
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\CustomerGroupProduct\Entity;
use Doctrine\ORM\Mapping as ORM;
use Eccube\Annotation\EntityExtension;
use Plugin\CustomerGroup\Entity\Group;
/**
* Class ProductTrait
* @package Plugin\CustomerGroupProduct\Entity
*
* @EntityExtension("Eccube\Entity\Product")
*/
trait ProductTrait
{
/**
* @var Group
*
* @ORM\ManyToOne(targetEntity="Plugin\CustomerGroup\Entity\Group")
* @ORM\JoinColumn(referencedColumnName="id")
*/
private $registerGroup;
/**
* @return Group|null
*/
public function getRegisterGroup(): ?Group
{
return $this->registerGroup;
}
/**
* @return bool
*/
public function hasRegisterGroup(): bool
{
return $this->registerGroup instanceof Group;
}
/**
* @param Group $registerGroup
* @return $this
*/
public function setRegisterGroup(Group $registerGroup): self
{
$this->registerGroup = $registerGroup;
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment