无论如何,在symfony2的EasyAdmin软件包中是否有一对多关系?

到目前为止,我让我的用户工作,但没有其他具有一对多关系的实体。

我有MySQL的数据库。

最佳答案

EasyAdminBundle支持各种实体关联。

没有关于实体关联的文档,因为它不是EasyAdminBundle的一部分,而是Doctrine。例如,这是一个一对多协会。

/**
 *
 * @var ArrayCollection
 * @ORM\OneToMany(targetEntity="DocumentBundle\Entity\Document", mappedBy="course")
 *
 */
private $documents;

public function __construct()
{
    $this->documents = new \Doctrine\Common\Collections\ArrayCollection();
}


这是协会的另一面

/**
 * Many-to-one relationship between documents and course
 *
 * @var ArrayCollection
 * @ORM\ManyToOne(targetEntity="CourseBundle\Entity\Course",inversedBy="documents")
 * @ORM\JoinColumn(name="course_id", referencedColumnName="id")
 */
private $course;


配置就像这样:

easy_admin:
    site_name: 'Learn-In Admin'
    entities:
        Courses:
            class: CourseBundle\Entity\Course
            new:
               fields: ['name','code']
        Documents:
            class: DocumentBundle\Entity\Document


您可以在Doctrine文档中找到有关Association Mapping的所有示例。

08-05 08:58
查看更多