# How to add belongsto association with \_joinData in cakephp 4.4

**URL:** <https://discourse.cakephp.org/t/how-to-add-belongsto-association-with-joindata-in-cakephp-4-4/11216>\
**Category:** Need Help\
**Created:** [May 13, 2023, 8:11pm UTC](https://discourse.cakephp.org/t/how-to-add-belongsto-association-with-joindata-in-cakephp-4-4/11216 "2023-05-13T20:11:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [May 13, 2023, 8:11pm UTC](https://discourse.cakephp.org/t/how-to-add-belongsto-association-with-joindata-in-cakephp-4-4/11216/1 "2023-05-13T20:11:52Z")

</div>

I have two tables with a belongstomany association (Events and Users, join table EventsUsers), the EventsUsers has a belongsto association with Supplies, how do I have to add the Supplies table in the contain of the index action?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [May 14, 2023, 10:51am UTC](https://discourse.cakephp.org/t/how-to-add-belongsto-association-with-joindata-in-cakephp-4-4/11216/2 "2023-05-14T10:51:24Z")

</div>

I don’t believe you can add to the contain of the `_joinData`. You’d need to add new associations from Events to EventsUsers, and EventsUsers to Users, and then `contain(['Events' => ['EventsUsers' => 'Supplies', 'Users'`, and change anything that’s referencing the `$event->_joinData` to something like `$event->events_user`.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [May 14, 2023, 4:54pm UTC](https://discourse.cakephp.org/t/how-to-add-belongsto-association-with-joindata-in-cakephp-4-4/11216/3 "2023-05-14T16:54:39Z")

</div>

Thank you Zuluru, that worked perfectly
