Skip to main content
adicionou 109 caracteres ao conteúdo
Fonte Link
Rodrigo Rigotti
  • 12,4mil
  • 3
  • 32
  • 52

Faça um relacionamento one to manyOneToMany.

Classe VendaVenda:

/**
 * @ORM\Entity
 * @ORM\Table(name="Venda")
 */
class Venda
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\OneToMany(targetEntity="ItensVenda", mappedBy="venda", cascade={"remove"})
     */
    protected $itensVenda;

    /** demais atraibutos**atributos**/
}

Classe ItensVendaItensVenda:

/**
  * @ORM\Entity
  * @ORM\Table(name="ItensVenda")
 */
class ItensVenda
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="Venda", inversedBy="itensVenda")
     * @ORM\JoinColumn(name="venda_id", referencedColumnName="id", nullable=FALSE)
     */
    protected $venda;

    /** demais atraibutos**atributos**/
}

Fonte

Faça um relacionamento one to many.

Classe Venda:

/**
* @ORM\Entity
* @ORM\Table(name="Venda")
*/
class Venda
{
/**
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue
 */
protected $id;

/**
 * @ORM\OneToMany(targetEntity="ItensVenda", mappedBy="venda", cascade={"remove"})
 */
protected $itensVenda;

/** demais atraibutos**/
}

Classe ItensVenda:

/**
  * @ORM\Entity
  * @ORM\Table(name="ItensVenda")
*/
class ItensVenda
{
/**
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue
 */
protected $id;

   /**
 * @ORM\ManyToOne(targetEntity="Venda", inversedBy="itensVenda")
 * @ORM\JoinColumn(name="venda_id", referencedColumnName="id", nullable=FALSE)
 */
protected $venda;

/** demais atraibutos**/
}

Fonte

Faça um relacionamento OneToMany.

Classe Venda:

/**
 * @ORM\Entity
 * @ORM\Table(name="Venda")
 */
class Venda
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\OneToMany(targetEntity="ItensVenda", mappedBy="venda", cascade={"remove"})
     */
    protected $itensVenda;

    /** demais atributos**/
}

Classe ItensVenda:

/**
 * @ORM\Entity
 * @ORM\Table(name="ItensVenda")
 */
class ItensVenda
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="Venda", inversedBy="itensVenda")
     * @ORM\JoinColumn(name="venda_id", referencedColumnName="id", nullable=FALSE)
     */
    protected $venda;

    /** demais atributos**/
}

Fonte

Fonte Link
LeoCBS
  • 1,2mil
  • 11
  • 27

Faça um relacionamento one to many.

Classe Venda:

/**
* @ORM\Entity
* @ORM\Table(name="Venda")
*/
class Venda
{
/**
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue
 */
protected $id;

/**
 * @ORM\OneToMany(targetEntity="ItensVenda", mappedBy="venda", cascade={"remove"})
 */
protected $itensVenda;

/** demais atraibutos**/
}

Classe ItensVenda:

/**
  * @ORM\Entity
  * @ORM\Table(name="ItensVenda")
*/
class ItensVenda
{
/**
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue
 */
protected $id;

   /**
 * @ORM\ManyToOne(targetEntity="Venda", inversedBy="itensVenda")
 * @ORM\JoinColumn(name="venda_id", referencedColumnName="id", nullable=FALSE)
 */
protected $venda;

/** demais atraibutos**/
}

Fonte