php - Additional field in Many to Many Relation -


this question has answer here:

users can see campaigns if they're assigned them. fact can see campaign doesn't mean they're participating it. want give opportunity user join campaign.

i use bidirectional, manytomany relation, table user_campaign created automatically. possibility add additional field participating? i'd rather not create new table.

entity user.php

/**  * @orm\manytomany(targetentity="reko\campaignbundle\entity\campaign", inversedby="users")  * @orm\orderby({"id" = "desc"})  * @orm\jointable(name="user_campaign")  */ protected $campaigns; 

entity campaign.php

/**  * @orm\manytomany(targetentity="reko\userbundle\entity\user", mappedby="campaigns")  */ protected $users; 

basicall need 2 manytomany relationships between users , campaigns. 1 representing assignments, 1 representing participation. since doctrine can automatically create 1 jointable have manually name 2 jointables differently in annotations , you're fine!


Comments