jeudi 21 mars 2019

Laravel set one object in relation to another multiple times

I want that a component can contain one component multiple times. This is a many to many relationship.

$component->contains()->sync($components);

Sync prevents multiple records. In other words I want that component with id 1 can be related to component 2 2 times.

$component->contains

This should return component 2 2 times.

Is there a posibility to do this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire