Skip to content

Multiple many to many relationships across multiple pivot tables #188

Answered by staudenmeir
idealerror asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @idealerror,
Define the relationship like this:

class Item extends Model
{
    use \Staudenmeir\EloquentHasManyDeep\HasRelationships;

    public function locations()
    {
        return $this->hasManyDeep(
            Location::class,
            ['menu_items', Menu::class, 'period_menus', Period::class, 'location_periods']
        );
    }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@idealerror
Comment options

Answer selected by idealerror
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants