Closed ryanmortier closed 2 months ago
Wait a second... this is just another belongsToMany
relationship. Duh. CampaignStatus
>---< Account
.
It never occured to me that the pivot is just a belongsToMany
from Account
to both Campaign
and CampaignStatus
.
I read through the docs but I'm having a difficult time understanding if this is possible.
I have the following models:
Account
Campaign
CampaignStatus
Account >---< Campaign (belongsToMany) Campaign ---< CampaignStatus (hasMany)
This is my table structure (simplified for this question):
When assigning an
account
to acampaign
, they are also assigned to acampaign status
via the pivot model.I want to define a relationship to get all accounts that are associated with a given
campaign status
so I can do something like$campaignStatus->accounts
.