HasMany using Pivot? #2326
              
                Unanswered
              
          
                  
                    
                      NiekNijland
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm trying to make a relation between my 2 MongoDB models. But instead of using the default way of pushing ID's to an array I want to use a Pivot Collection.
I could do this in the following way:
But I would prefer to return a Relation instead of a Collection, so I can query more efficiently on the relation, without fetching all of the Related Employees.
Here is what I have so far, but this is not working because I'm calling ->employees() on a Builder instance.
So I'm a bit lost now how I should try to setup this relation, so I'm asking here. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions