【发布时间】:2019-09-05 13:39:34
【问题描述】:
我有一个带有 User 实体和 SoldeConges 实体的 Symfony 4 项目。 一个用户有一个 SoldeConges 集合。
但是当我转储 $user->getSoldeConges() 时,集合是空的。
我的用户实体:
/**
* @ORM\OneToMany(targetEntity="App\Entity\SoldeConges", mappedBy="user", orphanRemoval=true)
*/
private $soldeConges;
/**
* @return Collection|SoldeConges[]
*/
public function getSoldeConges(): Collection
{
return $this->soldeConges;
}
我的用户有 3 个soldeConges:
PhpMyAdmin SoldeConge 表:
当我在控制器中为我的用户(即用户号 1)进行转储时:
$soldeConges = $this->getUser()->getSoldeConges();
dump($soldeConges);
我已经:
那么,为什么不能访问我的用户 SoldeConges 收藏?
【问题讨论】:
标签: symfony collections doctrine