[英]Could not determine access type for property “skills” in class “AppBundle\Entity\”
I make mapping manytomany in 2 entites but I have this error: 我在2个实体中映射了manytomany,但出现此错误:
Could not determine access type for property "skills" in class "AppBundle\\Entity\\".
无法确定类“ AppBundle \\ Entity \\”中属性“ skills”的访问类型。
code entity company: 代码实体公司:
/**
* @var SkillInterface[]
*
* @ORM\ManyToMany(targetEntity="Skill", inversedBy="companys", cascade={"all"})
* @ORM\JoinTable(name="companys_has_skills",
* joinColumns={
* @ORM\JoinColumn(name="company_id", referencedColumnName="id")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="skill_id", referencedColumnName="id")
* }
* )
* @Assert\Count(min = 1)
*/
private $skills;
public function __construct()
{
$this->skills = new ArrayCollection();
}
/**
* Add skills.
*
* @param SkillInterface $skills
*
* @return Company
*/
public function addSkills(\AppBundle\Entity\Skill $skills)
{
$this->skills[] = $skills;
return $this;
}
/**
* Remove skills.
*
* @param SkillInterface $skills
*/
public function removeSkills(\AppBundle\Entity\Skill $skills)
{
$this->skills->removeElement($skills);
}
/**
* Get skills.
*
* @return Collection
*/
public function getSkills()
{
return $this->skills;
}
code entity skill: 代码实体技能:
/**
* @var Collection
*
* @ORM\ManyToMany(targetEntity="Company", mappedBy="skills")
*/
private $companys;
/**
* Constructor.
*/
public function __construct()
{
$this->companys = new ArrayCollection();
}
/**
* Add company.
*
* @param \AppBundle\Entity\Company $company
*
* @return Skill
*/
public function addCompany(\AppBundle\Entity\Company $company)
{
$this->companys[] = $company;
return $this;
}
/**
* Remove company.
*
* @param \AppBundle\Entity\Company $company
*/
public function removeCompany(\AppBundle\Entity\Company $company)
{
$this->companys->removeElement($company);
}
/**
* Get companys.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCompanys()
{
return $this->companys;
}
now i make functions of remove ,add and get variables in 2 entitys but I have also error and I initialize to arrayCollection 现在我在2个实体中执行remove,add和get变量的函数,但是我也有错误,我初始化为arrayCollection
函数名称应为addSkill
和removeSkill
而不带s
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.