Code: Select all
Dish
Code: Select all
Ingredient
Code: Select all
#[ORM\Entity]
class Dish
{
#[ORM\OneToMany(
mappedBy: 'dish',
targetEntity: DishIngredient::class,
cascade: ['all'],
)]
private Collection $dishIngredients;
}
#[ORM\Entity]
class Ingredient
{
#[ORM\OneToMany(
mappedBy: 'ingredient',
targetEntity: DishIngredient::class,
cascade: ['all'],
)]
private Collection $dishIngredients;
}
#[ORM\Entity]
class DishIngredient
{
public function __construct(
#[
ORM\ManyToOne(
targetEntity: Dish::class,
),
ORM\JoinColumn(nullable: false),
]
private Dish $dish,
#[
ORM\ManyToOne(
targetEntity: Ingredient::class,
),
ORM\JoinColumn(nullable: false),
]
private Ingredient $ingredient,
#[ORM\Column(type: Types::INTEGER)]
private int $ingredientPosition = 0,
) {}
}