-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including support for composite primary keys #102
Comments
As stated in the documentation: There are situations where you'll need to match many columns in the definition of a relationship even when your models' tables have a single primary key. So, Compoships allows us to define relationships with multiple keys, but those keys can be any set of columns, not just primary keys. |
Hi @topclaudy , I fully understand your point. |
@pedrofmj Could you perhaps post the class? I would like to give it a try |
@sinnbeck , it's a trait, called HasCompositePrimaryKey. You need to use that trait in your model. It's also important to correctly set the primaryKey in the model, (ex.: protected $primaryKey = ['key1', 'key2', ...]). Here's the gist for the code: https://gist.github.com/pedrofmj/614061eff182626b7f2056073edc600e |
Hello,
I currently use compoships in conjunction with a Trait made by myself that enables Composite Primary Keys.
Would you guys think it would be useful and meaningful including such trait into Compoships?
Since we are talking about composite foreign keys in compoships, it onlly makes sense if we also we have support for composite primary keys.
If it makes sense, I could do some code for it.
What do you think?
The text was updated successfully, but these errors were encountered: